{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s133115082", "group_id": "codeNet:p00021", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n for (i in 1..n) {\n val (x1, y1, x2, y2) = Array(4, { sc.nextDouble() })\n val (x3, y3, x4, y4) = Array(4, { sc.nextDouble() })\n val (dx1, dx2) = Pair(x1 - x2, x3 - x4)\n val (dy1, dy2) = Pair(y1 - y2, y3 - y4)\n println(if (dx1 * dy2 == dx2 * dy1) \"YES\" else \"NO\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1528714176, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p00021.html", "problem_id": "p00021", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00021/input.txt", "sample_output_relpath": "derived/input_output/data/p00021/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00021/Kotlin/s133115082.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s133115082", "user_id": "u197615397"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n for (i in 1..n) {\n val (x1, y1, x2, y2) = Array(4, { sc.nextDouble() })\n val (x3, y3, x4, y4) = Array(4, { sc.nextDouble() })\n val (dx1, dx2) = Pair(x1 - x2, x3 - x4)\n val (dy1, dy2) = Pair(y1 - y2, y3 - y4)\n println(if (dx1 * dy2 == dx2 * dy1) \"YES\" else \"NO\")\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nParallelism\n\nThere are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints \"YES\" and if not prints \"NO\".\n\nInput\n\nInput consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \\leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$\n\nYou can assume that $-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \\leq 100$.\nEach value is a real number with at most 5 digits after the decimal point.\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0\n\nOutput for the Sample Input\n\nYES\nNO", "sample_input": "2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0\n"}, "reference_outputs": ["YES\nNO\n"], "source_document_id": "p00021", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nParallelism\n\nThere are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints \"YES\" and if not prints \"NO\".\n\nInput\n\nInput consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \\leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$\n\nYou can assume that $-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \\leq 100$.\nEach value is a real number with at most 5 digits after the decimal point.\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0\n\nOutput for the Sample Input\n\nYES\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 180, "memory_kb": 32456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s603126447", "group_id": "codeNet:p00512", "input_text": "import java.util.*\n\nobject ProductComparator : Comparator {\n override fun compare(o1: String, o2: String): Int {\n val compareLength = o1.length.compareTo(o2.length)\n if (compareLength != 0) {\n return compareLength\n }\n return o1.compareTo(o2)\n }\n}\n\nfun main(args: Array) {\n val treeMap = TreeMap(ProductComparator)\n (1..readInt())\n .mapNotNull { readLine() }\n .map { it.split(\" \") }\n .map { Pair(it[0], it[1].toInt()) }\n .forEach {\n var value = treeMap[it.first] ?: 0\n value += it.second\n treeMap[it.first] = it.second\n }\n treeMap.forEach { t, u ->\n println(\"$t $u\")\n }\n\n}\n\nfun readInt(): Int = readLine()?.toIntOrNull() ?: throw IllegalArgumentException(\"intではありません\")\n\n", "language": "Kotlin", "metadata": {"date": 1529024398, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p00512.html", "problem_id": "p00512", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00512/input.txt", "sample_output_relpath": "derived/input_output/data/p00512/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00512/Kotlin/s603126447.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s603126447", "user_id": "u827318431"}, "prompt_components": {"gold_output": "A 40\nB 20\nZ 10\nAB 10\n", "input_to_evaluate": "import java.util.*\n\nobject ProductComparator : Comparator {\n override fun compare(o1: String, o2: String): Int {\n val compareLength = o1.length.compareTo(o2.length)\n if (compareLength != 0) {\n return compareLength\n }\n return o1.compareTo(o2)\n }\n}\n\nfun main(args: Array) {\n val treeMap = TreeMap(ProductComparator)\n (1..readInt())\n .mapNotNull { readLine() }\n .map { it.split(\" \") }\n .map { Pair(it[0], it[1].toInt()) }\n .forEach {\n var value = treeMap[it.first] ?: 0\n value += it.second\n treeMap[it.first] = it.second\n }\n treeMap.forEach { t, u ->\n println(\"$t $u\")\n }\n\n}\n\nfun readInt(): Int = readLine()?.toIntOrNull() ?: throw IllegalArgumentException(\"intではありません\")\n\n", "problem_context": "問題 3\n\n ある工場では,各営業所から製品生産の注文を受けている.\n前日の注文をまとめて,各製品の生産合計を求めたい.\n\n 入力ファイルの1行目には注文データの数 n が書いてあり,\n続く n 行には製品名と注文数が空白で区切られて書いてある.\n製品名は5文字以内の英大文字で書かれている.\n注文データには同じ製品が含まれていることもあり,順序はバラバラである.\n\n この注文データの中に現れる同じ製品の注文数を合計し,\n出力ファイルに製品名と合計を空白を区切り文字として出力しなさい.\nただし,製品名に次の順序を付けて,その順で出力すること.\n\n 順序:文字の長さの小さい順に,同じ長さのときは,前から比べて\n最初に異なる文字のアルファベット順とする.\n\n入力データにおける製品数,注文数とその合計のどれも106以下である.\n\n 出力ファイルにおいては,\n出力の最後の行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n5\nA 20\nB 20\nA 20\nAB 10\nZ 10\n\n出力例1\n\nA 40\nB 20\nZ 10\nAB 10\n\n入力例2\n\n5\nAAA 20\nABA 20\nAAA 20\nAAB 20\nAAA 20\n\n出力例2\n\nAAA 60\nAAB 20\nABA 20\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5\nA 20\nB 20\nA 20\nAB 10\nZ 10\n"}, "reference_outputs": ["A 40\nB 20\nZ 10\nAB 10\n"], "source_document_id": "p00512", "source_text": "問題 3\n\n ある工場では,各営業所から製品生産の注文を受けている.\n前日の注文をまとめて,各製品の生産合計を求めたい.\n\n 入力ファイルの1行目には注文データの数 n が書いてあり,\n続く n 行には製品名と注文数が空白で区切られて書いてある.\n製品名は5文字以内の英大文字で書かれている.\n注文データには同じ製品が含まれていることもあり,順序はバラバラである.\n\n この注文データの中に現れる同じ製品の注文数を合計し,\n出力ファイルに製品名と合計を空白を区切り文字として出力しなさい.\nただし,製品名に次の順序を付けて,その順で出力すること.\n\n 順序:文字の長さの小さい順に,同じ長さのときは,前から比べて\n最初に異なる文字のアルファベット順とする.\n\n入力データにおける製品数,注文数とその合計のどれも106以下である.\n\n 出力ファイルにおいては,\n出力の最後の行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n5\nA 20\nB 20\nA 20\nAB 10\nZ 10\n\n出力例1\n\nA 40\nB 20\nZ 10\nAB 10\n\n入力例2\n\n5\nAAA 20\nABA 20\nAAA 20\nAAB 20\nAAA 20\n\n出力例2\n\nAAA 60\nAAB 20\nABA 20\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 876, "cpu_time_ms": 130, "memory_kb": 32208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s439459508", "group_id": "codeNet:p01268", "input_text": "fun solvePrimes(max: Int): List {\n val primes = mutableListOf()\n\n for (i in 2..max) {\n if (primes.none { prime -> i % prime == 0 }) primes += i\n }\n\n return primes\n}\n\nfun main(args: Array) {\n val primes = solvePrimes(100_600)\n\n while (true) {\n val (N, P) = readLine()!!.split(\" \").map { it.toInt() }\n if (N == -1 && P == -1) return\n\n val limitedPrimes = primes.filter { it > N }.take(P + 5)\n\n (0 until limitedPrimes.size)\n .asSequence()\n .map { left ->\n (left until limitedPrimes.size).map { right ->\n limitedPrimes[left] + limitedPrimes[right]\n }\n }\n .flatten()\n .sorted()\n .drop(P - 1)\n .firstOrNull()\n .run(::println)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1561107400, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p01268.html", "problem_id": "p01268", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01268/input.txt", "sample_output_relpath": "derived/input_output/data/p01268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01268/Kotlin/s439459508.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439459508", "user_id": "u261260518"}, "prompt_components": {"gold_output": "42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274\n", "input_to_evaluate": "fun solvePrimes(max: Int): List {\n val primes = mutableListOf()\n\n for (i in 2..max) {\n if (primes.none { prime -> i % prime == 0 }) primes += i\n }\n\n return primes\n}\n\nfun main(args: Array) {\n val primes = solvePrimes(100_600)\n\n while (true) {\n val (N, P) = readLine()!!.split(\" \").map { it.toInt() }\n if (N == -1 && P == -1) return\n\n val limitedPrimes = primes.filter { it > N }.take(P + 5)\n\n (0 until limitedPrimes.size)\n .asSequence()\n .map { left ->\n (left until limitedPrimes.size).map { right ->\n limitedPrimes[left] + limitedPrimes[right]\n }\n }\n .flatten()\n .sorted()\n .drop(P - 1)\n .firstOrNull()\n .run(::println)\n }\n}\n", "problem_context": "Problem B: Matsuzaki Number\n\nMatsuzaki 教授は,宇宙の真理を研究している科学者である.人生,宇宙,すべての答えは 42 であると言われているが,Matsuzaki 教授はこれだけでは宇宙の真理を解明するには不十分であると考えている.Matsuzaki 教授は,宇宙の真理は 2 つのパラメータからなる関数で表されると考えており,42 はその 1 つに過ぎないというのである.\n\nMatsuzaki 教授の定義した関数 M(N, P) は,N より大きい素数を 2 つ選んで(同じ数を 2 つでも構わない)和をとることで得られる数の全体を,小さいほうから順番に並べたときに,P 番目に現れる数を表す.ここで,2 通り以上の和で表されるような数も存在するが,そういった数は和の組み合わせの数と同じ個数だけ並べられる.\n\n例として N = 0 の場合を考えよう.このときは素数全体から 2 つを選んで和をとることになる.そういった和のうちで最小の数を考えると,同じ数を 2 回選ぶことも許されていることから,2 + 2 = 4 であることがわかる.すなわち M(0, 1) = 4 である.次に小さい数は 2 + 3 = 5 であるから M(0, 2) = 5 となる.同様にして考えると,和を並べたものは 4, 5, 6, 7, 8, 9, 10, 10, 12, 13, 14, 14, 16, ... のようになることがわかる.すなわち,たとえば M(0, 9) = 12 である.\n\n同じようにして N = 10 の場合を考えると,このときは 10 より大きい素数 {11, 13, 17, 19, ...} から 2 つを選ぶことになり,得られる和を小さいほうから並べると 22, 24, 26, 28, 30, 30, 32, ... のようになる.\n\nあなたの仕事は,N と P が与えられた時に M(N, P) を計算するプログラムを書くことである.\n\nInput\n\n入力は複数のデータセットからなる.データセットは 1 行であり,2 つの整数 N (0 ≤ N ≤ 100,000) と P (1 ≤ P ≤ 100) が 1 つの空白で区切られて与えられる.\n\n入力の終わりは,空白で区切られた 2 つの -1 を含む 1 行で示される.\n\nOutput\n\n各データセットに対して,M(N, P) の値を 1 行に出力せよ.出力に余計な空白や改行を含めてはならない.\n\nSample Input\n\n0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100000 100\n-1 -1\n\nOutput for the Sample Input\n\n42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274", "sample_input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100000 100\n-1 -1\n"}, "reference_outputs": ["42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274\n"], "source_document_id": "p01268", "source_text": "Problem B: Matsuzaki Number\n\nMatsuzaki 教授は,宇宙の真理を研究している科学者である.人生,宇宙,すべての答えは 42 であると言われているが,Matsuzaki 教授はこれだけでは宇宙の真理を解明するには不十分であると考えている.Matsuzaki 教授は,宇宙の真理は 2 つのパラメータからなる関数で表されると考えており,42 はその 1 つに過ぎないというのである.\n\nMatsuzaki 教授の定義した関数 M(N, P) は,N より大きい素数を 2 つ選んで(同じ数を 2 つでも構わない)和をとることで得られる数の全体を,小さいほうから順番に並べたときに,P 番目に現れる数を表す.ここで,2 通り以上の和で表されるような数も存在するが,そういった数は和の組み合わせの数と同じ個数だけ並べられる.\n\n例として N = 0 の場合を考えよう.このときは素数全体から 2 つを選んで和をとることになる.そういった和のうちで最小の数を考えると,同じ数を 2 回選ぶことも許されていることから,2 + 2 = 4 であることがわかる.すなわち M(0, 1) = 4 である.次に小さい数は 2 + 3 = 5 であるから M(0, 2) = 5 となる.同様にして考えると,和を並べたものは 4, 5, 6, 7, 8, 9, 10, 10, 12, 13, 14, 14, 16, ... のようになることがわかる.すなわち,たとえば M(0, 9) = 12 である.\n\n同じようにして N = 10 の場合を考えると,このときは 10 より大きい素数 {11, 13, 17, 19, ...} から 2 つを選ぶことになり,得られる和を小さいほうから並べると 22, 24, 26, 28, 30, 30, 32, ... のようになる.\n\nあなたの仕事は,N と P が与えられた時に M(N, P) を計算するプログラムを書くことである.\n\nInput\n\n入力は複数のデータセットからなる.データセットは 1 行であり,2 つの整数 N (0 ≤ N ≤ 100,000) と P (1 ≤ P ≤ 100) が 1 つの空白で区切られて与えられる.\n\n入力の終わりは,空白で区切られた 2 つの -1 を含む 1 行で示される.\n\nOutput\n\n各データセットに対して,M(N, P) の値を 1 行に出力せよ.出力に余計な空白や改行を含めてはならない.\n\nSample Input\n\n0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100000 100\n-1 -1\n\nOutput for the Sample Input\n\n42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 880, "cpu_time_ms": 1130, "memory_kb": 104932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s069579498", "group_id": "codeNet:p01310", "input_text": "fun main(args:Array):Unit {\n repeat(readLine()!!.toInt()){\n val (n, m, k) = readLine()!!.trim().split(' ').map(String::toInt)\n val borders = Array(m){\n val (h, x) = readLine()!!.split(' ').map(String::toInt)\n Pair(h, x - 1)\n }.sortedByDescending(Pair::first)\n val stripes = Array(n){it}\n borders.forEach { (_, x) ->\n val temp = stripes[x]\n stripes[x] = stripes[x + 1]\n stripes[x + 1] = temp\n }\n val goal = stripes[k - 1]\n val min = Array(n){ if (it > goal) it - goal else goal - it}\n for (i in 0 until n)\n stripes[i] = i\n borders.forEach{(_, x) ->\n val temp = stripes[x]\n stripes[x] = stripes[x + 1]\n stripes[x + 1] = temp\n if (x - 1 >= 0){\n val l = stripes[x - 1]\n val r = stripes[x]\n if (min[l] < min[r] - 1)\n min[r] = min[l] + 1\n if (min[r] < min[l] - 1)\n min[l] = min[r] + 1\n }\n if (x + 2 < n){\n val l = stripes[x + 1]\n val r = stripes[x + 2]\n if (min[l] < min[r] - 1)\n min[r] = min[l] + 1\n if (min[r] < min[l] - 1)\n min[l] = min[r] + 1\n }\n }\n min.forEach{println(it)}\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1528792894, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p01310.html", "problem_id": "p01310", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01310/input.txt", "sample_output_relpath": "derived/input_output/data/p01310/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01310/Kotlin/s069579498.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s069579498", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2\n", "input_to_evaluate": "fun main(args:Array):Unit {\n repeat(readLine()!!.toInt()){\n val (n, m, k) = readLine()!!.trim().split(' ').map(String::toInt)\n val borders = Array(m){\n val (h, x) = readLine()!!.split(' ').map(String::toInt)\n Pair(h, x - 1)\n }.sortedByDescending(Pair::first)\n val stripes = Array(n){it}\n borders.forEach { (_, x) ->\n val temp = stripes[x]\n stripes[x] = stripes[x + 1]\n stripes[x + 1] = temp\n }\n val goal = stripes[k - 1]\n val min = Array(n){ if (it > goal) it - goal else goal - it}\n for (i in 0 until n)\n stripes[i] = i\n borders.forEach{(_, x) ->\n val temp = stripes[x]\n stripes[x] = stripes[x + 1]\n stripes[x + 1] = temp\n if (x - 1 >= 0){\n val l = stripes[x - 1]\n val r = stripes[x]\n if (min[l] < min[r] - 1)\n min[r] = min[l] + 1\n if (min[r] < min[l] - 1)\n min[l] = min[r] + 1\n }\n if (x + 2 < n){\n val l = stripes[x + 1]\n val r = stripes[x + 2]\n if (min[l] < min[r] - 1)\n min[r] = min[l] + 1\n if (min[r] < min[l] - 1)\n min[l] = min[r] + 1\n }\n }\n min.forEach{println(it)}\n }\n}\n", "problem_context": "Problem H: あみだくじ\n\nなつめは大のねこ好きである。なつめは今日も日課としている野良ねこのブラッシングをするために,いつも野良ねこが集まってくる校庭の一角に向かうことにした。\n\nそのスポットに今日は n 匹のねこが集まってきた。なつめは全員をブラッシングしてやりたかったのだが,ちょうどそこに来る直前に突然用事が出来てしまい,時間的に一匹しかブラッシングしてやれないことになってしまった。ブラッシングはどのねこも楽しみにしているので,一匹だけやると他のねこが嫉妬してしまう。そこでねこたちを納得させるために,どのねこをブラッシングするかをあみだくじで決めることにした。\n\nあみだくじは n 本の縦線とあらかじめ引いた m 本の横線からなる。横線はとなりあう2本の縦線をそれらと垂直になるように結ばなければならない。また,横線同士が端点を共有してはいけない。ある1本の縦線の下端には当たりのマークがつけてある。これらの条件を満たすあみだくじの例を図に示す(これらはサンプル入力の例と対応している)。\n\n図: 問題の条件をみたすあみだくじの例\n\nねこたちはそれぞれ縦線の上端からどれか1つを選ぶ。そしてあみだくじを辿った結果,当たりをひいたねこが,今日のブラッシングをしてもらう権利を手に入れることができる,というルールである。なつめは早速あみだくじを作成した。縦線・横線・当たりを書き込み,横線が見えないように隠した。\n\nいよいよねこたちに選んでもらおうという時になって,なつめは n 匹のねこの中に,普段は顔を見せない野良ねこのアクタガワがいることに気がついた。アクタガワはもう一ヶ月ほどブラッシングをしておらず,毛がごわごわしている。\n\nなつめは他のねこたちには申し訳ないと思いながらも,ズルをしてアクタガワをブラッシングするように仕組むことにした。まず,ねこたちにそれぞれ普通通り縦線を選んでもらう。全員が選び終わったらなつめはこっそりといくつかの横線を追加し,アクタガワが当たるようにあみだくじを変更するのだ。\n\nしかし,アクタガワが選んだ縦線によってはアクタガワを当たりにするために新たに引かなければならない横線が多すぎて,細工をしている間にねこたちに計画がバレてしまうかもしれない。そこでなつめはまずそれぞれの縦線について,アクタガワがそれを選んだ場合に何本の横線を引けば当たりにすることができるかを求めることにした。\n\nなお,新たに引く横線も,となりあう2本の縦線をそれらと垂直に結ばなければならず,横線同士が端点を共有しないように引かなければならない。\n\nInput\n\n入力データは以下の形式で与えられる。\n\nn m k\n\nh1 x1\n\nh2 x2\n\n...\n\nhm xm\n\n入力の一行目には縦線の本数 n (1 ≤ n ≤ 100000),すでに引かれている横線の本数 m (0 ≤ m ≤ 100000),当たりの縦線の番号 k (1 ≤ k ≤ n) が与えられる。ここで,縦線の番号は,左から順に,1, 2, ..., n とする。\n\n続く m 行には横線の情報が与えられる。各行は一つの横線の情報を表す二つの整数 h (1 ≤ h ≤ 1000000) 及び x (1 ≤ x ≤ n - 1) が与えられる。h は縦線の下端からの距離,x は横線によって結ばれる縦線のうち,左側の縦線の番号である。つまり,この横線は x 番目と x+1 番目の縦線を結ぶことになる。\n\nなお、入力では横線は整数高さの位置にしか存在しないが、新たに追加する横棒の位置は必ずしも整数高さでなくてもよい。\n\nOutput\n\nn 行の文字列を出力せよ。 i (1 ≤ i ≤ n) 行目には,アクタガワが i 番目の縦線を選んだときに,アクタガワを当たりにするために追加する必要がある横線の最小本数を出力せよ。\n\nNotes on Submission\n\n上記形式で複数のデータセットが与えられます。入力データの 1 行目にデータセットの数が与えられます。各データセットに対する出力を上記形式で順番に出力するプログラムを作成して下さい。\n\nSample Input\n\n4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n4 2 1\n10 1\n10 3\n\nOutput for the Sample Input\n\n1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2", "sample_input": "4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n4 2 1\n10 1\n10 3\n"}, "reference_outputs": ["1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2\n"], "source_document_id": "p01310", "source_text": "Problem H: あみだくじ\n\nなつめは大のねこ好きである。なつめは今日も日課としている野良ねこのブラッシングをするために,いつも野良ねこが集まってくる校庭の一角に向かうことにした。\n\nそのスポットに今日は n 匹のねこが集まってきた。なつめは全員をブラッシングしてやりたかったのだが,ちょうどそこに来る直前に突然用事が出来てしまい,時間的に一匹しかブラッシングしてやれないことになってしまった。ブラッシングはどのねこも楽しみにしているので,一匹だけやると他のねこが嫉妬してしまう。そこでねこたちを納得させるために,どのねこをブラッシングするかをあみだくじで決めることにした。\n\nあみだくじは n 本の縦線とあらかじめ引いた m 本の横線からなる。横線はとなりあう2本の縦線をそれらと垂直になるように結ばなければならない。また,横線同士が端点を共有してはいけない。ある1本の縦線の下端には当たりのマークがつけてある。これらの条件を満たすあみだくじの例を図に示す(これらはサンプル入力の例と対応している)。\n\n図: 問題の条件をみたすあみだくじの例\n\nねこたちはそれぞれ縦線の上端からどれか1つを選ぶ。そしてあみだくじを辿った結果,当たりをひいたねこが,今日のブラッシングをしてもらう権利を手に入れることができる,というルールである。なつめは早速あみだくじを作成した。縦線・横線・当たりを書き込み,横線が見えないように隠した。\n\nいよいよねこたちに選んでもらおうという時になって,なつめは n 匹のねこの中に,普段は顔を見せない野良ねこのアクタガワがいることに気がついた。アクタガワはもう一ヶ月ほどブラッシングをしておらず,毛がごわごわしている。\n\nなつめは他のねこたちには申し訳ないと思いながらも,ズルをしてアクタガワをブラッシングするように仕組むことにした。まず,ねこたちにそれぞれ普通通り縦線を選んでもらう。全員が選び終わったらなつめはこっそりといくつかの横線を追加し,アクタガワが当たるようにあみだくじを変更するのだ。\n\nしかし,アクタガワが選んだ縦線によってはアクタガワを当たりにするために新たに引かなければならない横線が多すぎて,細工をしている間にねこたちに計画がバレてしまうかもしれない。そこでなつめはまずそれぞれの縦線について,アクタガワがそれを選んだ場合に何本の横線を引けば当たりにすることができるかを求めることにした。\n\nなお,新たに引く横線も,となりあう2本の縦線をそれらと垂直に結ばなければならず,横線同士が端点を共有しないように引かなければならない。\n\nInput\n\n入力データは以下の形式で与えられる。\n\nn m k\n\nh1 x1\n\nh2 x2\n\n...\n\nhm xm\n\n入力の一行目には縦線の本数 n (1 ≤ n ≤ 100000),すでに引かれている横線の本数 m (0 ≤ m ≤ 100000),当たりの縦線の番号 k (1 ≤ k ≤ n) が与えられる。ここで,縦線の番号は,左から順に,1, 2, ..., n とする。\n\n続く m 行には横線の情報が与えられる。各行は一つの横線の情報を表す二つの整数 h (1 ≤ h ≤ 1000000) 及び x (1 ≤ x ≤ n - 1) が与えられる。h は縦線の下端からの距離,x は横線によって結ばれる縦線のうち,左側の縦線の番号である。つまり,この横線は x 番目と x+1 番目の縦線を結ぶことになる。\n\nなお、入力では横線は整数高さの位置にしか存在しないが、新たに追加する横棒の位置は必ずしも整数高さでなくてもよい。\n\nOutput\n\nn 行の文字列を出力せよ。 i (1 ≤ i ≤ n) 行目には,アクタガワが i 番目の縦線を選んだときに,アクタガワを当たりにするために追加する必要がある横線の最小本数を出力せよ。\n\nNotes on Submission\n\n上記形式で複数のデータセットが与えられます。入力データの 1 行目にデータセットの数が与えられます。各データセットに対する出力を上記形式で順番に出力するプログラムを作成して下さい。\n\nSample Input\n\n4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n4 2 1\n10 1\n10 3\n\nOutput for the Sample Input\n\n1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1424, "cpu_time_ms": 5340, "memory_kb": 198576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s495846475", "group_id": "codeNet:p02235", "input_text": "fun main(args: Array) {\n val MAX = 1000\n var N = Integer.parseInt(readLine());\n var L = Array(MAX+1) { _ -> IntArray(MAX+1) };\n \n for (x in 1..N) {\n val a = readLine();\n val b = readLine();\n \n val n = a!!.length;\n val m = b!!.length;\n \n for (i in 0..(n-1)) {\n for (j in 0..(m-1)) {\n if (a[i] == b[j]) {\n L[i+1][j+1] = L[i][j] + 1\n } else {\n L[i+1][j+1] = if (L[i+1][j] > L[i][j+1]) {\n L[i+1][j]\n } else {\n L[i][j+1]\n }\n }\n }\n }\n println(L[n][m]);\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1571099676, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02235.html", "problem_id": "p02235", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02235/input.txt", "sample_output_relpath": "derived/input_output/data/p02235/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02235/Kotlin/s495846475.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495846475", "user_id": "u137240270"}, "prompt_components": {"gold_output": "4\n3\n2\n", "input_to_evaluate": "fun main(args: Array) {\n val MAX = 1000\n var N = Integer.parseInt(readLine());\n var L = Array(MAX+1) { _ -> IntArray(MAX+1) };\n \n for (x in 1..N) {\n val a = readLine();\n val b = readLine();\n \n val n = a!!.length;\n val m = b!!.length;\n \n for (i in 0..(n-1)) {\n for (j in 0..(m-1)) {\n if (a[i] == b[j]) {\n L[i+1][j+1] = L[i][j] + 1\n } else {\n L[i+1][j+1] = if (L[i+1][j] > L[i][j+1]) {\n L[i+1][j]\n } else {\n L[i][j+1]\n }\n }\n }\n }\n println(L[n][m]);\n }\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nLongest Common Subsequence\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater.\n\nWrite a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.\n\nInput\n\nThe input consists of multiple datasets. In the first line, an integer $q$ which is the number of datasets is given. In the following $2 \\times q$ lines, each dataset which consists of the two sequences $X$ and $Y$ are given.\n\nOutput\n\nFor each dataset, print the length of LCS of $X$ and $Y$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 150$\n\n$1 \\leq$ length of $X$ and $Y$ $\\leq 1,000$\n\n$q \\leq 20$ if the dataset includes a sequence whose length is more than 100\n\nSample Input 1\n\n3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n\nSample Output 1\n\n4\n3\n2\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n"}, "reference_outputs": ["4\n3\n2\n"], "source_document_id": "p02235", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nLongest Common Subsequence\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater.\n\nWrite a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.\n\nInput\n\nThe input consists of multiple datasets. In the first line, an integer $q$ which is the number of datasets is given. In the following $2 \\times q$ lines, each dataset which consists of the two sequences $X$ and $Y$ are given.\n\nOutput\n\nFor each dataset, print the length of LCS of $X$ and $Y$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 150$\n\n$1 \\leq$ length of $X$ and $Y$ $\\leq 1,000$\n\n$q \\leq 20$ if the dataset includes a sequence whose length is more than 100\n\nSample Input 1\n\n3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n\nSample Output 1\n\n4\n3\n2\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 731, "cpu_time_ms": 200, "memory_kb": 33712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s770718049", "group_id": "codeNet:p02255", "input_text": "\nfun trace(a: IntArray) = println(a.joinToString(separator = \" \"))\n\nfun insertionSort(a: IntArray?) {\n a?.let {\n trace(a)\n for (i in 1 until a.size) {\n val pivotVal = a[i]\n val pivotIdx = (a.slice(0 until i)).indexOfFirst { it > pivotVal }\n if (pivotIdx != -1) {\n (i downTo pivotIdx+1).forEach { a[it] = a[it-1] }\n a[pivotIdx] = pivotVal\n }\n trace(a)\n }\n }\n}\n\nfun main(args: Array) {\n readLine()\n readLine()\n ?.split(\"\"\"\\s+\"\"\".toRegex())\n ?.map { it.toInt() }\n ?.toIntArray()\n ?.let { insertionSort(it) }\n\n}\n", "language": "Kotlin", "metadata": {"date": 1522242336, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02255.html", "problem_id": "p02255", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02255/input.txt", "sample_output_relpath": "derived/input_output/data/p02255/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02255/Kotlin/s770718049.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770718049", "user_id": "u407262649"}, "prompt_components": {"gold_output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n", "input_to_evaluate": "\nfun trace(a: IntArray) = println(a.joinToString(separator = \" \"))\n\nfun insertionSort(a: IntArray?) {\n a?.let {\n trace(a)\n for (i in 1 until a.size) {\n val pivotVal = a[i]\n val pivotIdx = (a.slice(0 until i)).indexOfFirst { it > pivotVal }\n if (pivotIdx != -1) {\n (i downTo pivotIdx+1).forEach { a[it] = a[it-1] }\n a[pivotIdx] = pivotVal\n }\n trace(a)\n }\n }\n}\n\nfun main(args: Array) {\n readLine()\n readLine()\n ?.split(\"\"\"\\s+\"\"\".toRegex())\n ?.map { it.toInt() }\n ?.toIntArray()\n ?.let { insertionSort(it) }\n\n}\n", "problem_context": "Insertion Sort\n\nWrite a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] = A[j]\nj--\nA[j+1] = key\n\nNote that, indices for array elements are based on 0-origin.\n\nTo illustrate the algorithms, your program should trace intermediate result for each step.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by a single space.\n\nOutput\n\nThe output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 2 4 6 1 3\n\nSample Output 1\n\n5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n1 2 3\n1 2 3\n1 2 3\n\nHint\n\nTemplate in C", "sample_input": "6\n5 2 4 6 1 3\n"}, "reference_outputs": ["5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n"], "source_document_id": "p02255", "source_text": "Insertion Sort\n\nWrite a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] = A[j]\nj--\nA[j+1] = key\n\nNote that, indices for array elements are based on 0-origin.\n\nTo illustrate the algorithms, your program should trace intermediate result for each step.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by a single space.\n\nOutput\n\nThe output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 2 4 6 1 3\n\nSample Output 1\n\n5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n1 2 3\n1 2 3\n1 2 3\n\nHint\n\nTemplate in C", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 678, "cpu_time_ms": 140, "memory_kb": 33548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s697931567", "group_id": "codeNet:p02257", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n try {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n var c = 0\n for (i in 0 until n) {\n val a = sc.nextInt()\n if (a < 2 || a > 100_000_000) {\n throw Exception(\"Illegal input.\")\n }\n if (isPrimeFast(a)) c++\n }\n println(c)\n } catch (e: Exception) {\n println(e)\n }\n}\n\nfun isPrimeFast(a: Int): Boolean {\n val p = Math.sqrt(a.toDouble()).toInt()\n for (i in 2..p) {\n if (a % i == 0) {\n return false\n }\n }\n return true\n}\n\nfun isPrimeSlow(a: Int): Boolean {\n for (i in 2..a) {\n if (a % i == 0) {\n return false\n }\n }\n return true\n}\n\n", "language": "Kotlin", "metadata": {"date": 1565311308, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02257.html", "problem_id": "p02257", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02257/input.txt", "sample_output_relpath": "derived/input_output/data/p02257/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02257/Kotlin/s697931567.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697931567", "user_id": "u490902542"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n try {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n var c = 0\n for (i in 0 until n) {\n val a = sc.nextInt()\n if (a < 2 || a > 100_000_000) {\n throw Exception(\"Illegal input.\")\n }\n if (isPrimeFast(a)) c++\n }\n println(c)\n } catch (e: Exception) {\n println(e)\n }\n}\n\nfun isPrimeFast(a: Int): Boolean {\n val p = Math.sqrt(a.toDouble()).toInt()\n for (i in 2..p) {\n if (a % i == 0) {\n return false\n }\n }\n return true\n}\n\nfun isPrimeSlow(a: Int): Boolean {\n for (i in 2..a) {\n if (a % i == 0) {\n return false\n }\n }\n return true\n}\n\n", "problem_context": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "sample_input": "5\n2\n3\n4\n5\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02257", "source_text": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 777, "cpu_time_ms": 240, "memory_kb": 41384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s552218619", "group_id": "codeNet:p02257", "input_text": "import java.lang.Math.sqrt\n\nfun main(args: Array) {\n val array = IntArray(readLine()?.toInt() ?: 0) {\n readLine()?.toInt() ?: 0\n }\n val primeJudge = PrimeJudge(array.max() ?: 0)\n println(array.filter(primeJudge::isPrime).count())\n}\n\nclass PrimeJudge(max: Int) {\n private val numArray = BooleanArray(max+1) { true }\n init {\n numArray[0] = false\n numArray[1] = false\n for (i in 2..sqrt(numArray.size.toDouble()).toInt()) {\n if (numArray[i]) {\n for (j in i * 2 until numArray.size step i) {\n numArray[j] = false\n }\n }\n }\n }\n fun isPrime(num: Int) = numArray[num]\n}\n", "language": "Kotlin", "metadata": {"date": 1544405619, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02257.html", "problem_id": "p02257", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02257/input.txt", "sample_output_relpath": "derived/input_output/data/p02257/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02257/Kotlin/s552218619.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552218619", "user_id": "u462634153"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.lang.Math.sqrt\n\nfun main(args: Array) {\n val array = IntArray(readLine()?.toInt() ?: 0) {\n readLine()?.toInt() ?: 0\n }\n val primeJudge = PrimeJudge(array.max() ?: 0)\n println(array.filter(primeJudge::isPrime).count())\n}\n\nclass PrimeJudge(max: Int) {\n private val numArray = BooleanArray(max+1) { true }\n init {\n numArray[0] = false\n numArray[1] = false\n for (i in 2..sqrt(numArray.size.toDouble()).toInt()) {\n if (numArray[i]) {\n for (j in i * 2 until numArray.size step i) {\n numArray[j] = false\n }\n }\n }\n }\n fun isPrime(num: Int) = numArray[num]\n}\n", "problem_context": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "sample_input": "5\n2\n3\n4\n5\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02257", "source_text": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 700, "cpu_time_ms": 1070, "memory_kb": 132612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s058978528", "group_id": "codeNet:p02258", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val r = IntArray(200000)\n\n for (i in 0 until n) {\n r[i] = readLine()!!.toInt()\n }\n\n var maxv = -2000000000\n var minv = r[0]\n\n for (i in 1 until n) {\n maxv = Math.max(maxv, r[i] - minv)\n minv = Math.min(minv, r[i])\n }\n\n println(maxv)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1568041405, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Kotlin/s058978528.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s058978528", "user_id": "u641702731"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val r = IntArray(200000)\n\n for (i in 0 until n) {\n r[i] = readLine()!!.toInt()\n }\n\n var maxv = -2000000000\n var minv = r[0]\n\n for (i in 1 until n) {\n maxv = Math.max(maxv, r[i] - minv)\n minv = Math.min(minv, r[i])\n }\n\n println(maxv)\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 210, "memory_kb": 45332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s722301960", "group_id": "codeNet:p02259", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n\n var flag = true\n var i = 0\n var count = 0\n while (flag) {\n flag = false\n for (j in n - 1 downTo i + 1) {\n if (a[j] < a[j - 1]) {\n var temp = a[j]\n a[j] = a[j - 1]\n a[j - 1] = temp\n flag = true\n count++\n }\n }\n i++\n }\n\n println(a.joinToString(\" \"))\n println(count)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1595908662, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02259.html", "problem_id": "p02259", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02259/input.txt", "sample_output_relpath": "derived/input_output/data/p02259/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02259/Kotlin/s722301960.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722301960", "user_id": "u353409014"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n\n var flag = true\n var i = 0\n var count = 0\n while (flag) {\n flag = false\n for (j in n - 1 downTo i + 1) {\n if (a[j] < a[j - 1]) {\n var temp = a[j]\n a[j] = a[j - 1]\n a[j - 1] = temp\n flag = true\n count++\n }\n }\n i++\n }\n\n println(a.joinToString(\" \"))\n println(count)\n}\n\n", "problem_context": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "sample_input": "5\n5 3 2 4 1\n"}, "reference_outputs": ["1 2 3 4 5\n8\n"], "source_document_id": "p02259", "source_text": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 547, "cpu_time_ms": 130, "memory_kb": 33944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s248763393", "group_id": "codeNet:p02259", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val array = readLine()!!.split(\" \").map { it.toInt() } as MutableList\n val (sortedArray, exchanges) = bubbleSort(n, array)\n println(sortedArray.joinToString(\" \"))\n println(exchanges)\n}\n\nfun bubbleSort(n: Int, array: MutableList): Pair, Int> {\n var head = 0\n var exchanges = 0\n while (head < n - 1) {\n\n for (j in n - 1 downTo head + 1) {\n if (array[j] < array[j - 1]) {\n val small = array[j]\n val large = array[j - 1]\n array[j] = large\n array[j - 1] = small\n exchanges++\n }\n }\n head ++\n }\n return array to exchanges\n}\n", "language": "Kotlin", "metadata": {"date": 1593616240, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02259.html", "problem_id": "p02259", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02259/input.txt", "sample_output_relpath": "derived/input_output/data/p02259/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02259/Kotlin/s248763393.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s248763393", "user_id": "u191141806"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val array = readLine()!!.split(\" \").map { it.toInt() } as MutableList\n val (sortedArray, exchanges) = bubbleSort(n, array)\n println(sortedArray.joinToString(\" \"))\n println(exchanges)\n}\n\nfun bubbleSort(n: Int, array: MutableList): Pair, Int> {\n var head = 0\n var exchanges = 0\n while (head < n - 1) {\n\n for (j in n - 1 downTo head + 1) {\n if (array[j] < array[j - 1]) {\n val small = array[j]\n val large = array[j - 1]\n array[j] = large\n array[j - 1] = small\n exchanges++\n }\n }\n head ++\n }\n return array to exchanges\n}\n", "problem_context": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "sample_input": "5\n5 3 2 4 1\n"}, "reference_outputs": ["1 2 3 4 5\n8\n"], "source_document_id": "p02259", "source_text": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 748, "cpu_time_ms": 170, "memory_kb": 32148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s274731068", "group_id": "codeNet:p02259", "input_text": "fun main(args: Array) {\n readLine()\n val array = readLine()\n ?.split(\"\\\\s+\".toRegex())\n ?.map(String::toInt)\n ?.toIntArray()\n ?:intArrayOf()\n var cnt = 0\n for (i in array.indices) {\n for (j in array.size - 2 downTo i) {\n if (array[j] > array[j+1]) {\n array.swap(j, j+1)\n cnt++\n }\n }\n }\n println(array.joinToString(\" \"))\n println(cnt)\n}\n\nfun IntArray.swap(i: Int, j: Int) {\n val tmp = this[i]\n this[i] = this[j]\n this[j] = tmp\n}\n", "language": "Kotlin", "metadata": {"date": 1544147599, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02259.html", "problem_id": "p02259", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02259/input.txt", "sample_output_relpath": "derived/input_output/data/p02259/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02259/Kotlin/s274731068.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s274731068", "user_id": "u462634153"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()\n val array = readLine()\n ?.split(\"\\\\s+\".toRegex())\n ?.map(String::toInt)\n ?.toIntArray()\n ?:intArrayOf()\n var cnt = 0\n for (i in array.indices) {\n for (j in array.size - 2 downTo i) {\n if (array[j] > array[j+1]) {\n array.swap(j, j+1)\n cnt++\n }\n }\n }\n println(array.joinToString(\" \"))\n println(cnt)\n}\n\nfun IntArray.swap(i: Int, j: Int) {\n val tmp = this[i]\n this[i] = this[j]\n this[j] = tmp\n}\n", "problem_context": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "sample_input": "5\n5 3 2 4 1\n"}, "reference_outputs": ["1 2 3 4 5\n8\n"], "source_document_id": "p02259", "source_text": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 488, "cpu_time_ms": 130, "memory_kb": 29588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s545450560", "group_id": "codeNet:p02264", "input_text": "data class Process(val id: String, val time: Int)\n\nclass Queue(private val maxSize: Int) {\n\n private val elements = arrayListOf()\n\n fun isEmpty() = elements.size == 0\n\n fun isFull() = elements.size == maxSize\n\n fun enqueue(element: T) {\n if (isFull()) throw Exception(\"error\")\n elements.add(element)\n }\n\n fun dequeue(): T {\n if (isEmpty()) throw Exception(\"error\")\n return elements.removeAt(0)\n }\n}\n\nfun main(args: Array) {\n val (n, q) = readLine()!!.split(\" \").map(String::toInt)\n val queue = Queue(n)\n (1..n).forEach {\n val (id, t) = readLine()!!.split(\" \")\n queue.enqueue(Process(id, t.toInt()))\n }\n\n var count = 0\n while (!queue.isEmpty()) {\n val process = queue.dequeue()\n if (process.time <= q) {\n count += process.time\n val id = process.id\n println(\"$id $count\")\n } else {\n queue.enqueue(Process(process.id, process.time - q))\n count += q\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1562468229, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02264.html", "problem_id": "p02264", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02264/input.txt", "sample_output_relpath": "derived/input_output/data/p02264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02264/Kotlin/s545450560.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545450560", "user_id": "u208877383"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "data class Process(val id: String, val time: Int)\n\nclass Queue(private val maxSize: Int) {\n\n private val elements = arrayListOf()\n\n fun isEmpty() = elements.size == 0\n\n fun isFull() = elements.size == maxSize\n\n fun enqueue(element: T) {\n if (isFull()) throw Exception(\"error\")\n elements.add(element)\n }\n\n fun dequeue(): T {\n if (isEmpty()) throw Exception(\"error\")\n return elements.removeAt(0)\n }\n}\n\nfun main(args: Array) {\n val (n, q) = readLine()!!.split(\" \").map(String::toInt)\n val queue = Queue(n)\n (1..n).forEach {\n val (id, t) = readLine()!!.split(\" \")\n queue.enqueue(Process(id, t.toInt()))\n }\n\n var count = 0\n while (!queue.isEmpty()) {\n val process = queue.dequeue()\n if (process.time <= q) {\n count += process.time\n val id = process.id\n println(\"$id $count\")\n } else {\n queue.enqueue(Process(process.id, process.time - q))\n count += q\n }\n }\n}\n", "problem_context": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "sample_input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n"}, "reference_outputs": ["p2 180\np5 400\np1 450\np3 550\np4 800\n"], "source_document_id": "p02264", "source_text": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1044, "cpu_time_ms": 950, "memory_kb": 75424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s582315661", "group_id": "codeNet:p02271", "input_text": "package com.example.alds1.Five\n\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = IntArray(n).map { sc.nextInt() }.toIntArray()\n val q = sc.nextInt()\n for (i in 0 until q) {\n if (combination(a, sc.nextInt())) {\n println(\"yes\")\n } else {\n println(\"no\")\n }\n }\n}\n\nfun combination(a: IntArray, m: Int, i: Int = 0): Boolean {\n if (m == 0) {\n return true\n }\n if (i >= a.size) {\n return false\n }\n\n return combination(a, m, i + 1) || combination(a, m - a[i], i + 1)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1588502395, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02271.html", "problem_id": "p02271", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02271/input.txt", "sample_output_relpath": "derived/input_output/data/p02271/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02271/Kotlin/s582315661.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s582315661", "user_id": "u490902542"}, "prompt_components": {"gold_output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n", "input_to_evaluate": "package com.example.alds1.Five\n\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = IntArray(n).map { sc.nextInt() }.toIntArray()\n val q = sc.nextInt()\n for (i in 0 until q) {\n if (combination(a, sc.nextInt())) {\n println(\"yes\")\n } else {\n println(\"no\")\n }\n }\n}\n\nfun combination(a: IntArray, m: Int, i: Int = 0): Boolean {\n if (m == 0) {\n return true\n }\n if (i >= a.size) {\n return false\n }\n\n return combination(a, m, i + 1) || combination(a, m - a[i], i + 1)\n}\n\n", "problem_context": "Exhaustive Search\n\nWrite a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.\n\nOutput\n\nFor each question Mi, print yes or no.\n\nConstraints\n\nn ≤ 20\n\nq ≤ 200\n\n1 ≤ elements in A ≤ 2000\n\n1 ≤ Mi ≤ 2000\n\nSample Input 1\n\n5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n\nSample Output 1\n\nno\nno\nyes\nyes\nyes\nyes\nno\nno\n\nNotes\n\nYou can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:\n\nsolve(0, M)\n\nsolve(1, M-{sum created from elements before 1st element})\n\nsolve(2, M-{sum created from elements before 2nd element})\n\n...\n\nThe recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.\n\nFor example, the following figure shows that 8 can be made by A[0] + A[2].", "sample_input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n"}, "reference_outputs": ["no\nno\nyes\nyes\nyes\nyes\nno\nno\n"], "source_document_id": "p02271", "source_text": "Exhaustive Search\n\nWrite a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.\n\nOutput\n\nFor each question Mi, print yes or no.\n\nConstraints\n\nn ≤ 20\n\nq ≤ 200\n\n1 ≤ elements in A ≤ 2000\n\n1 ≤ Mi ≤ 2000\n\nSample Input 1\n\n5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n\nSample Output 1\n\nno\nno\nyes\nyes\nyes\nyes\nno\nno\n\nNotes\n\nYou can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:\n\nsolve(0, M)\n\nsolve(1, M-{sum created from elements before 1st element})\n\nsolve(2, M-{sum created from elements before 2nd element})\n\n...\n\nThe recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.\n\nFor example, the following figure shows that 8 can be made by A[0] + A[2].", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 530, "memory_kb": 28324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192732748", "group_id": "codeNet:p02275", "input_text": "fun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val n = Integer.parseInt(reader.readLine())\n val input = reader.readLine().split(\" \".toRegex())\n val array = IntArray(n) { Integer.parseInt(input[it]) }\n array.cSort()\n}\n\nfun IntArray.cSort() {\n val countArray = IntArray((this.max() ?: 0) + 1) { 0 }\n for (i in this) {\n countArray[i]++\n }\n for (i in 1 until countArray.size) {\n countArray[i] += countArray[i - 1]\n }\n val ansArray = IntArray(this.size)\n for (i in ansArray.size-1 downTo 0) {\n ansArray[countArray[this[i]] - 1] = this[i]\n countArray[this[i]]--\n }\n println(ansArray.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1545383054, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02275/input.txt", "sample_output_relpath": "derived/input_output/data/p02275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02275/Kotlin/s192732748.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s192732748", "user_id": "u462634153"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "fun main(args: Array) {\n val reader = System.`in`.bufferedReader()\n val n = Integer.parseInt(reader.readLine())\n val input = reader.readLine().split(\" \".toRegex())\n val array = IntArray(n) { Integer.parseInt(input[it]) }\n array.cSort()\n}\n\nfun IntArray.cSort() {\n val countArray = IntArray((this.max() ?: 0) + 1) { 0 }\n for (i in this) {\n countArray[i]++\n }\n for (i in 1 until countArray.size) {\n countArray[i] += countArray[i - 1]\n }\n val ansArray = IntArray(this.size)\n for (i in ansArray.size-1 downTo 0) {\n ansArray[countArray[this[i]] - 1] = this[i]\n countArray[this[i]]--\n }\n println(ansArray.joinToString(\" \"))\n}\n", "problem_context": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "sample_input": "7\n2 5 1 3 2 3 0\n"}, "reference_outputs": ["0 1 2 2 3 3 5\n"], "source_document_id": "p02275", "source_text": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 697, "cpu_time_ms": 3910, "memory_kb": 320440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s514478121", "group_id": "codeNet:p02280", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nval sc = Scanner(System.`in`)\n\nclass Node(var par:Int, var lef: Int,var rig:Int) {\n fun show(){\n println(\"par: ${this.par}, lef: ${this.lef}, rig: ${this.rig}\")\n }\n}\n\nfun main(args: Array) {\n val n = nextInt()\n val fig = Array(n){Node(-1, -1, -1)}\n for(i in 0 until n){\n val (id, lef, rig) = nextListOfInt()\n fig[id].lef = lef\n fig[id].rig = rig\n if(lef != -1) fig[lef].par = id\n if(rig != -1) fig[rig].par = id\n }\n\n var root = -1\n for(i in 0 until n) {\n if (fig[i].par == -1) root = i\n }\n\n val H = Array(n){-1}\n val D = Array(n){-1}\n\n setHigh(fig, H, root)\n setDep(fig, D, root, 0)\n\n\n for(i in 0 until n){\n println(\"node $i: parent = ${fig[i].par}, sibling = ${getSib(fig, i, root)}, degree = ${getDeg(fig, i, root).first},\" +\n \" depth = ${D[i]}, height = ${H[i]}, ${getDeg(fig, i, root).second}\")\n }\n}\n\nfun setHigh(fig: Array, H :Array, u :Int) : Int {\n var h1 = 0\n var h2 =0\n if(fig[u].rig != -1) h1 = setHigh(fig, H, fig[u].rig) + 1\n if(fig[u].lef != -1) h2 = setHigh(fig, H, fig[u].lef) + 1\n H[u] = Math.max(h1, h2)\n return Math.max(h1, h2)\n}\n\nfun setDep(fig: Array, D :Array, u :Int, d :Int) {\n if(u == -1) return\n D[u] = d\n setDep(fig, D, fig[u].rig, d+1)\n setDep(fig, D, fig[u].lef, d+1)\n}\n\nfun getSib(fig :Array, u :Int, root :Int) : Int{\n if(u == root) return -1\n if(fig[fig[u].par].rig != -1 && fig[fig[u].par].rig != u) return fig[fig[u].par].rig\n if(fig[fig[u].par].lef != -1 && fig[fig[u].par].lef != u) return fig[fig[u].par].lef\n return -1\n}\n\nfun getDeg(fig: Array, u: Int, root: Int) : Pair {\n var deg = 0\n var type: String\n if(fig[u].rig != -1) deg++\n if(fig[u].lef != -1) deg++\n type = if(deg == 0) \"leaf\" else \"internal node\"\n if(u == root) type = \"root\"\n return Pair(deg, type)\n}\n\n\nfun abc000a() {\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextListOfString() = next().split(\" \")\nfun nextListOfInt() = nextListOfString().map { it.toInt() }\nfun nextListOfLong() = nextListOfString().map { it.toLong() }\nfun nextListOfDouble() = nextListOfString().map { it.toDouble() }\n", "language": "Kotlin", "metadata": {"date": 1590394410, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02280.html", "problem_id": "p02280", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02280/input.txt", "sample_output_relpath": "derived/input_output/data/p02280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02280/Kotlin/s514478121.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s514478121", "user_id": "u333478394"}, "prompt_components": {"gold_output": "node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nval sc = Scanner(System.`in`)\n\nclass Node(var par:Int, var lef: Int,var rig:Int) {\n fun show(){\n println(\"par: ${this.par}, lef: ${this.lef}, rig: ${this.rig}\")\n }\n}\n\nfun main(args: Array) {\n val n = nextInt()\n val fig = Array(n){Node(-1, -1, -1)}\n for(i in 0 until n){\n val (id, lef, rig) = nextListOfInt()\n fig[id].lef = lef\n fig[id].rig = rig\n if(lef != -1) fig[lef].par = id\n if(rig != -1) fig[rig].par = id\n }\n\n var root = -1\n for(i in 0 until n) {\n if (fig[i].par == -1) root = i\n }\n\n val H = Array(n){-1}\n val D = Array(n){-1}\n\n setHigh(fig, H, root)\n setDep(fig, D, root, 0)\n\n\n for(i in 0 until n){\n println(\"node $i: parent = ${fig[i].par}, sibling = ${getSib(fig, i, root)}, degree = ${getDeg(fig, i, root).first},\" +\n \" depth = ${D[i]}, height = ${H[i]}, ${getDeg(fig, i, root).second}\")\n }\n}\n\nfun setHigh(fig: Array, H :Array, u :Int) : Int {\n var h1 = 0\n var h2 =0\n if(fig[u].rig != -1) h1 = setHigh(fig, H, fig[u].rig) + 1\n if(fig[u].lef != -1) h2 = setHigh(fig, H, fig[u].lef) + 1\n H[u] = Math.max(h1, h2)\n return Math.max(h1, h2)\n}\n\nfun setDep(fig: Array, D :Array, u :Int, d :Int) {\n if(u == -1) return\n D[u] = d\n setDep(fig, D, fig[u].rig, d+1)\n setDep(fig, D, fig[u].lef, d+1)\n}\n\nfun getSib(fig :Array, u :Int, root :Int) : Int{\n if(u == root) return -1\n if(fig[fig[u].par].rig != -1 && fig[fig[u].par].rig != u) return fig[fig[u].par].rig\n if(fig[fig[u].par].lef != -1 && fig[fig[u].par].lef != u) return fig[fig[u].par].lef\n return -1\n}\n\nfun getDeg(fig: Array, u: Int, root: Int) : Pair {\n var deg = 0\n var type: String\n if(fig[u].rig != -1) deg++\n if(fig[u].lef != -1) deg++\n type = if(deg == 0) \"leaf\" else \"internal node\"\n if(u == root) type = \"root\"\n return Pair(deg, type)\n}\n\n\nfun abc000a() {\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextListOfString() = next().split(\" \")\nfun nextListOfInt() = nextListOfString().map { it.toInt() }\nfun nextListOfLong() = nextListOfString().map { it.toLong() }\nfun nextListOfDouble() = nextListOfString().map { it.toDouble() }\n", "problem_context": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n"}, "reference_outputs": ["node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n"], "source_document_id": "p02280", "source_text": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2393, "cpu_time_ms": 200, "memory_kb": 32984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s853667764", "group_id": "codeNet:p02315", "input_text": "/**\n * ナップザック問題\n * @link http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp\n */\nfun main(args: Array) {\n Main.init()\n\n Main.execute()\n\n Main.display()\n}\n\nclass Main {\n companion object {\n\n private val DEFAULT_VALUE = 0\n\n private val matrix = arrayListOf()\n\n private var maxWeight: Int = 0\n private var itemNum: Int = 0\n\n\n private lateinit var itemList: List\n\n fun init() {\n val (inputItemNum, inputMaxWeight) = readLine()!!.split(\" \")\n itemNum = inputItemNum.toInt()\n maxWeight = inputMaxWeight.toInt()\n\n itemList = List(itemNum) {\n val (value, weight) = readLine()!!.split(\" \")\n Item(weight = weight.toInt(), value = value.toInt())\n }\n\n // matrixを準備\n for (index in 1..itemNum) {\n matrix.add(this.getEmptyMatrixRow())\n }\n }\n\n fun getEmptyMatrixRow(): IntArray {\n return IntArray(maxWeight + 1) {\n DEFAULT_VALUE\n }\n }\n\n\n fun execute() {\n /**\n * matrixを走査\n */\n var round = 0\n while (itemList.lastIndex >= round) {\n val item = itemList[round]\n\n val currentRound = matrix[round]\n val previewRound =\n if (round == 0) this.getEmptyMatrixRow() else matrix[round - 1]\n\n\n for (weight in 0 until currentRound.size) {\n\n val valueWhenNone = previewRound[weight]\n\n if (weight - item.weight < 0) {\n currentRound[weight] = valueWhenNone\n continue\n }\n\n val valueWhenAdded = currentRound[weight - item.weight] + item.value\n\n if (valueWhenAdded > valueWhenNone) {\n currentRound[weight] = valueWhenAdded\n } else {\n currentRound[weight] = valueWhenNone\n }\n }\n round++\n }\n }\n\n fun display() {\n // 最大の値を出力\n println(matrix.last().max())\n }\n }\n}\n\ndata class Item(val weight: Int, val value: Int)\n", "language": "Kotlin", "metadata": {"date": 1556756067, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02315.html", "problem_id": "p02315", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02315/input.txt", "sample_output_relpath": "derived/input_output/data/p02315/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02315/Kotlin/s853667764.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s853667764", "user_id": "u142244215"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "/**\n * ナップザック問題\n * @link http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp\n */\nfun main(args: Array) {\n Main.init()\n\n Main.execute()\n\n Main.display()\n}\n\nclass Main {\n companion object {\n\n private val DEFAULT_VALUE = 0\n\n private val matrix = arrayListOf()\n\n private var maxWeight: Int = 0\n private var itemNum: Int = 0\n\n\n private lateinit var itemList: List\n\n fun init() {\n val (inputItemNum, inputMaxWeight) = readLine()!!.split(\" \")\n itemNum = inputItemNum.toInt()\n maxWeight = inputMaxWeight.toInt()\n\n itemList = List(itemNum) {\n val (value, weight) = readLine()!!.split(\" \")\n Item(weight = weight.toInt(), value = value.toInt())\n }\n\n // matrixを準備\n for (index in 1..itemNum) {\n matrix.add(this.getEmptyMatrixRow())\n }\n }\n\n fun getEmptyMatrixRow(): IntArray {\n return IntArray(maxWeight + 1) {\n DEFAULT_VALUE\n }\n }\n\n\n fun execute() {\n /**\n * matrixを走査\n */\n var round = 0\n while (itemList.lastIndex >= round) {\n val item = itemList[round]\n\n val currentRound = matrix[round]\n val previewRound =\n if (round == 0) this.getEmptyMatrixRow() else matrix[round - 1]\n\n\n for (weight in 0 until currentRound.size) {\n\n val valueWhenNone = previewRound[weight]\n\n if (weight - item.weight < 0) {\n currentRound[weight] = valueWhenNone\n continue\n }\n\n val valueWhenAdded = currentRound[weight - item.weight] + item.value\n\n if (valueWhenAdded > valueWhenNone) {\n currentRound[weight] = valueWhenAdded\n } else {\n currentRound[weight] = valueWhenNone\n }\n }\n round++\n }\n }\n\n fun display() {\n // 最大の値を出力\n println(matrix.last().max())\n }\n }\n}\n\ndata class Item(val weight: Int, val value: Int)\n", "problem_context": "0-1 Knapsack Problem\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\nThe total value of the items is as large as possible.\n\nThe items have combined weight at most W, that is capacity of the knapsack.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1\nv2 w2\n:\nvN wN\n\nThe first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.\n\nOutput\n\nPrint the maximum total values of the items in a line.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ vi ≤ 1000\n\n1 ≤ wi ≤ 1000\n\n1 ≤ W ≤ 10000\n\nSample Input 1\n\n4 5\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n\n13\n\nSample Input 2\n\n2 20\n5 9\n4 10\n\nSample Output 2\n\n9", "sample_input": "4 5\n4 2\n5 2\n2 1\n8 3\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02315", "source_text": "0-1 Knapsack Problem\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\nThe total value of the items is as large as possible.\n\nThe items have combined weight at most W, that is capacity of the knapsack.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1\nv2 w2\n:\nvN wN\n\nThe first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.\n\nOutput\n\nPrint the maximum total values of the items in a line.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ vi ≤ 1000\n\n1 ≤ wi ≤ 1000\n\n1 ≤ W ≤ 10000\n\nSample Input 1\n\n4 5\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n\n13\n\nSample Input 2\n\n2 20\n5 9\n4 10\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2360, "cpu_time_ms": 130, "memory_kb": 31328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s947684201", "group_id": "codeNet:p02388", "input_text": "import java.util.Scanner\nfun main(args: Array){\n val sc = Scanner(System.`in`) //Scannerのインスタンスを作成\n\n val s: String = sc.nextLine() //入力を行で取得\n val i: Int = Integer.parseInt(s)//Int型に変換\n println(i*i*i)\n}\n", "language": "Kotlin", "metadata": {"date": 1586174438, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Kotlin/s947684201.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947684201", "user_id": "u820893325"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\nfun main(args: Array){\n val sc = Scanner(System.`in`) //Scannerのインスタンスを作成\n\n val s: String = sc.nextLine() //入力を行で取得\n val i: Int = Integer.parseInt(s)//Int型に変換\n println(i*i*i)\n}\n", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 90, "memory_kb": 25636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s798621562", "group_id": "codeNet:p02389", "input_text": "fun main(args: Array) {\n val list = readLine()!!.split(\" \").map(String::toInt)\n println(\"%d %d\".format(list[0] * list[1], (list[0] * 2) + (list[1] * 2)))\n}\n", "language": "Kotlin", "metadata": {"date": 1590561841, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02389.html", "problem_id": "p02389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02389/input.txt", "sample_output_relpath": "derived/input_output/data/p02389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02389/Kotlin/s798621562.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s798621562", "user_id": "u706470580"}, "prompt_components": {"gold_output": "15 16\n", "input_to_evaluate": "fun main(args: Array) {\n val list = readLine()!!.split(\" \").map(String::toInt)\n println(\"%d %d\".format(list[0] * list[1], (list[0] * 2) + (list[1] * 2)))\n}\n", "problem_context": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "sample_input": "3 5\n"}, "reference_outputs": ["15 16\n"], "source_document_id": "p02389", "source_text": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 170, "cpu_time_ms": 120, "memory_kb": 31964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s407629699", "group_id": "codeNet:p02389", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n print(a*b)\n print(\" \")\n println(2*a+2*b)\n}\n", "language": "Kotlin", "metadata": {"date": 1578142013, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02389.html", "problem_id": "p02389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02389/input.txt", "sample_output_relpath": "derived/input_output/data/p02389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02389/Kotlin/s407629699.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s407629699", "user_id": "u853741520"}, "prompt_components": {"gold_output": "15 16\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n print(a*b)\n print(\" \")\n println(2*a+2*b)\n}\n", "problem_context": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "sample_input": "3 5\n"}, "reference_outputs": ["15 16\n"], "source_document_id": "p02389", "source_text": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 110, "memory_kb": 26476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s144718780", "group_id": "codeNet:p02389", "input_text": "fun main(args: Array) {\n val (a,b) = readLine()!!.split(\" \").map(String::toInt)\n println(\"${a*b} ${(a+b)*2}\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1568003386, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02389.html", "problem_id": "p02389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02389/input.txt", "sample_output_relpath": "derived/input_output/data/p02389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02389/Kotlin/s144718780.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s144718780", "user_id": "u641702731"}, "prompt_components": {"gold_output": "15 16\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,b) = readLine()!!.split(\" \").map(String::toInt)\n println(\"${a*b} ${(a+b)*2}\")\n}\n\n", "problem_context": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "sample_input": "3 5\n"}, "reference_outputs": ["15 16\n"], "source_document_id": "p02389", "source_text": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 123, "cpu_time_ms": 120, "memory_kb": 31720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s225044687", "group_id": "codeNet:p02391", "input_text": "fun main(args: Array){\n val inputs: List = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n when {\n inputs[0] < inputs[1] -> println(\"${inputs[0]} < ${inputs[1]}\")\n inputs[0] > inputs[1] -> println(\"${inputs[0]} > ${inputs[1]}\")\n else -> println(\"${inputs[0]} == ${inputs[1]}\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1515140214, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02391/input.txt", "sample_output_relpath": "derived/input_output/data/p02391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02391/Kotlin/s225044687.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s225044687", "user_id": "u418130569"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "fun main(args: Array){\n val inputs: List = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n when {\n inputs[0] < inputs[1] -> println(\"${inputs[0]} < ${inputs[1]}\")\n inputs[0] > inputs[1] -> println(\"${inputs[0]} > ${inputs[1]}\")\n else -> println(\"${inputs[0]} == ${inputs[1]}\")\n }\n}\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 140, "memory_kb": 30552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s556323925", "group_id": "codeNet:p02391", "input_text": "fun main(args: Array) {\n val list: List = readLine()!!.split(\" \").map { it.toInt() }\n val a = list[0]\n val b = list[1]\n val com = when {\n a < b -> \"a < b\"\n a > b -> \"a > b\"\n else -> \"a == b\"\n }\n println(com)\n}\n", "language": "Kotlin", "metadata": {"date": 1594545737, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02391/input.txt", "sample_output_relpath": "derived/input_output/data/p02391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02391/Kotlin/s556323925.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s556323925", "user_id": "u142722681"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "fun main(args: Array) {\n val list: List = readLine()!!.split(\" \").map { it.toInt() }\n val a = list[0]\n val b = list[1]\n val com = when {\n a < b -> \"a < b\"\n a > b -> \"a > b\"\n else -> \"a == b\"\n }\n println(com)\n}\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 250, "cpu_time_ms": 140, "memory_kb": 31984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s357189721", "group_id": "codeNet:p02391", "input_text": "fun main(args: Array) {\n val input = readLine()?.split(\" \")\n val a = input?.get(0)?.toInt() ?: 0\n val b = input?.get(1)?.toInt() ?: 0\n\n when {\n a > b -> println(\"a > b\")\n a < b -> println(\"a < b\")\n else -> println(\"a == b\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1561426251, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02391/input.txt", "sample_output_relpath": "derived/input_output/data/p02391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02391/Kotlin/s357189721.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357189721", "user_id": "u973626357"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()?.split(\" \")\n val a = input?.get(0)?.toInt() ?: 0\n val b = input?.get(1)?.toInt() ?: 0\n\n when {\n a > b -> println(\"a > b\")\n a < b -> println(\"a < b\")\n else -> println(\"a == b\")\n }\n}\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 273, "cpu_time_ms": 130, "memory_kb": 31988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s537194551", "group_id": "codeNet:p02393", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\tval scan = Scanner(System.`in`)\n\tval a = scan.nextInt()\n\tval b = scan.nextInt()\n\tval c = scan.nextInt()\n\tprintln(arrayOf(a, b, c).sortedArray().joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1524115178, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02393.html", "problem_id": "p02393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02393/input.txt", "sample_output_relpath": "derived/input_output/data/p02393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02393/Kotlin/s537194551.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s537194551", "user_id": "u550895675"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\tval scan = Scanner(System.`in`)\n\tval a = scan.nextInt()\n\tval b = scan.nextInt()\n\tval c = scan.nextInt()\n\tprintln(arrayOf(a, b, c).sortedArray().joinToString(\" \"))\n}\n", "problem_context": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "sample_input": "3 8 1\n"}, "reference_outputs": ["1 3 8\n"], "source_document_id": "p02393", "source_text": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 218, "cpu_time_ms": 140, "memory_kb": 30052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s705679638", "group_id": "codeNet:p02394", "input_text": "fun main(args: Array) {\n val (W, H, x, y, r) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(\n if (x - r < 0 || y - r < 0 || x + r > W || y + r > H) {\n \"No\"\n } else {\n \"Yes\"\n }\n )\n\n}\n\n", "language": "Kotlin", "metadata": {"date": 1538491004, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02394.html", "problem_id": "p02394", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02394/input.txt", "sample_output_relpath": "derived/input_output/data/p02394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02394/Kotlin/s705679638.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s705679638", "user_id": "u973203074"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (W, H, x, y, r) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(\n if (x - r < 0 || y - r < 0 || x + r > W || y + r > H) {\n \"No\"\n } else {\n \"Yes\"\n }\n )\n\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "sample_input": "5 4 2 2 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02394", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 271, "cpu_time_ms": 170, "memory_kb": 33948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s587004294", "group_id": "codeNet:p02396", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\tval scan = Scanner(\"\"\"\n\n\t\"\"\")\n\tvar i = 0\n\twhile (scan.hasNext()) {\n\t\tval a = scan.nextInt()\n\t\tif (a == 0) break\n\t\ti++\n\t\tprintln(\"Case $i: $a\")\n\t}\n}\n", "language": "Kotlin", "metadata": {"date": 1524117628, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02396/input.txt", "sample_output_relpath": "derived/input_output/data/p02396/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02396/Kotlin/s587004294.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s587004294", "user_id": "u550895675"}, "prompt_components": {"gold_output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\tval scan = Scanner(\"\"\"\n\n\t\"\"\")\n\tvar i = 0\n\twhile (scan.hasNext()) {\n\t\tval a = scan.nextInt()\n\t\tif (a == 0) break\n\t\ti++\n\t\tprintln(\"Case $i: $a\")\n\t}\n}\n", "problem_context": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "sample_input": "3\n5\n11\n7\n8\n19\n0\n"}, "reference_outputs": ["Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n"], "source_document_id": "p02396", "source_text": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 80, "memory_kb": 24940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s693527930", "group_id": "codeNet:p02396", "input_text": "fun main(args: Array) {\n var r = readLine()\n var i=1\n while(r != \"0\") {\n println(\"Case ${i}: ${r}\")\n i+=1\n r = readLine()\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1529758536, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02396/input.txt", "sample_output_relpath": "derived/input_output/data/p02396/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02396/Kotlin/s693527930.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693527930", "user_id": "u508732591"}, "prompt_components": {"gold_output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n", "input_to_evaluate": "fun main(args: Array) {\n var r = readLine()\n var i=1\n while(r != \"0\") {\n println(\"Case ${i}: ${r}\")\n i+=1\n r = readLine()\n }\n}\n", "problem_context": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "sample_input": "3\n5\n11\n7\n8\n19\n0\n"}, "reference_outputs": ["Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n"], "source_document_id": "p02396", "source_text": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 168, "cpu_time_ms": 260, "memory_kb": 34504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s607768060", "group_id": "codeNet:p02398", "input_text": "fun main(args: Array) {\n val input = readLine()?.split(' ')?.map{Integer.parseInt(it)} ?: listOf(0,0,0)\n println((input[0]..input[1]).toList().count {input[2] % it == 0 })\n}\n\n", "language": "Kotlin", "metadata": {"date": 1566122196, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Kotlin/s607768060.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s607768060", "user_id": "u600584317"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()?.split(' ')?.map{Integer.parseInt(it)} ?: listOf(0,0,0)\n println((input[0]..input[1]).toList().count {input[2] % it == 0 })\n}\n\n", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 180, "memory_kb": 33072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s174924670", "group_id": "codeNet:p02399", "input_text": "import java.math.BigDecimal\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val a =scanner.nextInt()\n val b =scanner.nextInt()\n val d = a / b\n val r = a % b\n val f = BigDecimal(a.toDouble() / b)\n println(\"$d $r ${f.toPlainString()}\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1579957079, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02399/input.txt", "sample_output_relpath": "derived/input_output/data/p02399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02399/Kotlin/s174924670.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s174924670", "user_id": "u684367399"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "import java.math.BigDecimal\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val a =scanner.nextInt()\n val b =scanner.nextInt()\n val d = a / b\n val r = a % b\n val f = BigDecimal(a.toDouble() / b)\n println(\"$d $r ${f.toPlainString()}\")\n}\n\n", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 299, "cpu_time_ms": 100, "memory_kb": 25632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s233649549", "group_id": "codeNet:p02400", "input_text": "fun main(args: Array) {\n val PI = 3.141592653589793\n val r = readLine()!!.toDouble()\n println(\"%f %f\".format(r*r*PI, 2*r*PI))\n}\n", "language": "Kotlin", "metadata": {"date": 1572489347, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02400.html", "problem_id": "p02400", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02400/input.txt", "sample_output_relpath": "derived/input_output/data/p02400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02400/Kotlin/s233649549.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233649549", "user_id": "u994101591"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "fun main(args: Array) {\n val PI = 3.141592653589793\n val r = readLine()!!.toDouble()\n println(\"%f %f\".format(r*r*PI, 2*r*PI))\n}\n", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 90, "memory_kb": 25488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s109381885", "group_id": "codeNet:p02403", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n val cin = Scanner(System.`in`)\n\n while(true){\n\tval h = cin.nextInt()\n\tval w = cin.nextInt()\n\n\tif(h == 0 && w == 0){\n\t break\n\t}else{\n for(i in 1..h){\n\t for(j in 1..w){\n\t print(\"#\")\n\t }\n println(\"\")\n }\n\t}\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1540298860, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Kotlin/s109381885.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s109381885", "user_id": "u837508455"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n val cin = Scanner(System.`in`)\n\n while(true){\n\tval h = cin.nextInt()\n\tval w = cin.nextInt()\n\n\tif(h == 0 && w == 0){\n\t break\n\t}else{\n for(i in 1..h){\n\t for(j in 1..w){\n\t print(\"#\")\n\t }\n println(\"\")\n }\n\t}\n }\n}\n\n", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 80, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s864302617", "group_id": "codeNet:p02403", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n val cin = Scanner(System.`in`)\n\n while(true){\n\tval h = cin.nextInt()\n\tval w = cin.nextInt()\n\n\tif(h == 0 && w == 0){\n\t print(\"%n\".format())\n\t break\n\t}else{\n for(i in 1..h){\n\t for(j in 1..w){\n\t print(\"#\")\n\t }\n print(\"%n\".format())\n }\n\t}\n }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1540299002, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Kotlin/s864302617.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s864302617", "user_id": "u837508455"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n val cin = Scanner(System.`in`)\n\n while(true){\n\tval h = cin.nextInt()\n\tval w = cin.nextInt()\n\n\tif(h == 0 && w == 0){\n\t print(\"%n\".format())\n\t break\n\t}else{\n for(i in 1..h){\n\t for(j in 1..w){\n\t print(\"#\")\n\t }\n print(\"%n\".format())\n }\n\t}\n }\n}\n\n\n", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 372, "cpu_time_ms": 100, "memory_kb": 24940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s921745410", "group_id": "codeNet:p02404", "input_text": "fun main(args: Array) {\n while (true) {\n val (H, W) = readLine()!!.split(\" \").map(String::toInt)\n if (H == 0 && W == 0) break\n println(\"#\".repeat(W))\n print(\"#${\".\".repeat(W-2)}#\\n\".repeat(H-2))\n println(\"#\".repeat(W))\n println()\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1576154210, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02404.html", "problem_id": "p02404", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02404/input.txt", "sample_output_relpath": "derived/input_output/data/p02404/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02404/Kotlin/s921745410.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s921745410", "user_id": "u294922877"}, "prompt_components": {"gold_output": "####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n", "input_to_evaluate": "fun main(args: Array) {\n while (true) {\n val (H, W) = readLine()!!.split(\" \").map(String::toInt)\n if (H == 0 && W == 0) break\n println(\"#\".repeat(W))\n print(\"#${\".\".repeat(W-2)}#\\n\".repeat(H-2))\n println(\"#\".repeat(W))\n println()\n }\n}\n", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 291, "cpu_time_ms": 130, "memory_kb": 31792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s069339218", "group_id": "codeNet:p02408", "input_text": "val SUITS_LIST = arrayListOf(\"S\",\"H\",\"C\",\"D\")\nval NUM_LIST = arrayListOf(1..13)\n\nfun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val allCards : HashMap = hashMapOf()\n (1..n).forEach {\n val suitAndNum= readLine() ?: return\n allCards[suitAndNum] = true\n }\n val lostCards: ArrayList = arrayListOf()\n SUITS_LIST.forEach{ suit ->\n NUM_LIST.forEach{ num ->\n val suitAndNum = \"$suit $num\"\n if(allCards[suitAndNum] == null) lostCards.add(suitAndNum)\n }\n }\n lostCards.forEach { suitAndNum ->\n println(suitAndNum)\n }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1515558542, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02408.html", "problem_id": "p02408", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02408/input.txt", "sample_output_relpath": "derived/input_output/data/p02408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02408/Kotlin/s069339218.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s069339218", "user_id": "u418130569"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "val SUITS_LIST = arrayListOf(\"S\",\"H\",\"C\",\"D\")\nval NUM_LIST = arrayListOf(1..13)\n\nfun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val allCards : HashMap = hashMapOf()\n (1..n).forEach {\n val suitAndNum= readLine() ?: return\n allCards[suitAndNum] = true\n }\n val lostCards: ArrayList = arrayListOf()\n SUITS_LIST.forEach{ suit ->\n NUM_LIST.forEach{ num ->\n val suitAndNum = \"$suit $num\"\n if(allCards[suitAndNum] == null) lostCards.add(suitAndNum)\n }\n }\n lostCards.forEach { suitAndNum ->\n println(suitAndNum)\n }\n}\n\n\n", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 646, "cpu_time_ms": 80, "memory_kb": 28448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s497556588", "group_id": "codeNet:p02410", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n\n val cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val m = cin.nextInt()\n\n var mat = Array(n,{ Array(m,{0}) })\n var vec = Array(m,{0})\n var result:Int = 0\n\n for(i in 0..n-1){\n\t for(j in 0..m-1){\n\t mat[i][j] = cin.nextInt()\n\t }\n }\n\n for(i in 0..m-1) vec[i] = cin.nextInt()\n\n for(i in 0..n-1){\n\t for(j in 0..m-1){\n\t result += mat[i][j] * vec[j]\n\t }\n\t println(result)\n\t result = 0\n }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1541856399, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02410.html", "problem_id": "p02410", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02410/input.txt", "sample_output_relpath": "derived/input_output/data/p02410/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02410/Kotlin/s497556588.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s497556588", "user_id": "u837508455"}, "prompt_components": {"gold_output": "5\n6\n9\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n\n val cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val m = cin.nextInt()\n\n var mat = Array(n,{ Array(m,{0}) })\n var vec = Array(m,{0})\n var result:Int = 0\n\n for(i in 0..n-1){\n\t for(j in 0..m-1){\n\t mat[i][j] = cin.nextInt()\n\t }\n }\n\n for(i in 0..m-1) vec[i] = cin.nextInt()\n\n for(i in 0..n-1){\n\t for(j in 0..m-1){\n\t result += mat[i][j] * vec[j]\n\t }\n\t println(result)\n\t result = 0\n }\n}\n\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "sample_input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n"}, "reference_outputs": ["5\n6\n9\n"], "source_document_id": "p02410", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 522, "cpu_time_ms": 210, "memory_kb": 40804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s134719630", "group_id": "codeNet:p02412", "input_text": "fun main(args: Array) {\n while (true) {\n val (n, x) = readLine()!!.split(\" \").map { it.toInt() }\n if (n == 0 && x == 0) break\n var count = 0\n for (i in 1..n) {\n for (j in i..n) {\n for (k in j..n) {\n if (i != j && j != k && i + j + k == x ) count ++\n }\n }\n }\n println(count)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592385617, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02412.html", "problem_id": "p02412", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02412/input.txt", "sample_output_relpath": "derived/input_output/data/p02412/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02412/Kotlin/s134719630.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s134719630", "user_id": "u191141806"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n while (true) {\n val (n, x) = readLine()!!.split(\" \").map { it.toInt() }\n if (n == 0 && x == 0) break\n var count = 0\n for (i in 1..n) {\n for (j in i..n) {\n for (k in j..n) {\n if (i != j && j != k && i + j + k == x ) count ++\n }\n }\n }\n println(count)\n }\n}\n", "problem_context": "How many ways?\n\nWrite a program which identifies the number of combinations of three integers which satisfy the following conditions:\n\nYou should select three distinct integers from 1 to n.\n\nA total sum of the three integers is x.\n\nFor example, there are two combinations for n = 5 and x = 9.\n\n1 + 3 + 5 = 9\n\n2 + 3 + 4 = 9\n\nInput\n\nThe input consists of multiple datasets. For each dataset, two integers n and x are given in a line.\n\nThe input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.\n\nConstraints\n\n3 ≤ n ≤ 100\n\n0 ≤ x ≤ 300\n\nOutput\n\nFor each dataset, print the number of combinations in a line.\n\nSample Input\n\n5 9\n0 0\n\nSample Output\n\n2\n\nNote\n\n      解説", "sample_input": "5 9\n0 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02412", "source_text": "How many ways?\n\nWrite a program which identifies the number of combinations of three integers which satisfy the following conditions:\n\nYou should select three distinct integers from 1 to n.\n\nA total sum of the three integers is x.\n\nFor example, there are two combinations for n = 5 and x = 9.\n\n1 + 3 + 5 = 9\n\n2 + 3 + 4 = 9\n\nInput\n\nThe input consists of multiple datasets. For each dataset, two integers n and x are given in a line.\n\nThe input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.\n\nConstraints\n\n3 ≤ n ≤ 100\n\n0 ≤ x ≤ 300\n\nOutput\n\nFor each dataset, print the number of combinations in a line.\n\nSample Input\n\n5 9\n0 0\n\nSample Output\n\n2\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 406, "cpu_time_ms": 180, "memory_kb": 32076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s793806771", "group_id": "codeNet:p02420", "input_text": "fun main(args: Array) {\n while (true) {\n var s = readLine()!!.toString()\n if (s == \"-\") break\n val m = readLine()!!.toInt()\n val h = (0 until m).map { readLine()!!.toInt() }\n h.forEach { i ->\n s = s.slice(i until s.length) + s.slice(0 until i)\n }\n println(s)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1578401709, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02420.html", "problem_id": "p02420", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02420/input.txt", "sample_output_relpath": "derived/input_output/data/p02420/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02420/Kotlin/s793806771.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s793806771", "user_id": "u294922877"}, "prompt_components": {"gold_output": "aabc\nxyzvw\n", "input_to_evaluate": "fun main(args: Array) {\n while (true) {\n var s = readLine()!!.toString()\n if (s == \"-\") break\n val m = readLine()!!.toInt()\n val h = (0 until m).map { readLine()!!.toInt() }\n h.forEach { i ->\n s = s.slice(i until s.length) + s.slice(0 until i)\n }\n println(s)\n }\n}\n", "problem_context": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "sample_input": "aabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n"}, "reference_outputs": ["aabc\nxyzvw\n"], "source_document_id": "p02420", "source_text": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 130, "memory_kb": 24488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s183643988", "group_id": "codeNet:p02432", "input_text": "\n\nfun main(args:Array):Unit {\n val vector = Vector()\n repeat(readLine()!!.toInt()){\n val arg = readLine()!!.split(' ').map(String::toInt)\n when(arg.first()){\n 0 -> when(arg[1]){\n 0 -> vector.pushFront(arg.last())\n else -> vector.pushBack(arg.last())\n }\n 1 -> println(vector[arg.last()])\n else -> when(arg[1]){\n 0 -> vector.popFront()\n else -> vector.popBack()\n }\n }\n }\n}\n\nclass Vector {\n var capacity:Int = 10000\n private set\n private var mHead:Int = 0//[mHead, mEnd)\n private var mEnd:Int = 0\n private var size:Int = 0\n private var mArray:Array = Array(10000){0}\n private fun resize():Unit {\n val newArray = Array(capacity * 2){0}\n for (i in 0 until size){\n newArray[i] = mArray[(i + mHead) % capacity]\n }\n capacity *= 2\n mHead = 0\n mEnd = size\n mArray = newArray\n }\n fun pushBack(value:Int):Unit {\n if (size == capacity) resize()\n mArray[mEnd] = value\n mEnd = (mEnd + 1) % capacity\n ++size\n }\n fun pushFront(value:Int):Unit {\n if (size == capacity) resize()\n mHead = (mHead + capacity - 1) % capacity\n mArray[mHead] = value\n ++size\n }\n fun popBack():Unit {\n mEnd = (mEnd + capacity - 1) % capacity\n }\n fun popFront():Unit {\n mHead = (mHead + 1) % capacity\n }\n operator fun get(index:Int):Int = mArray[(mHead + index) % capacity]\n}\n", "language": "Kotlin", "metadata": {"date": 1528506205, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02432.html", "problem_id": "p02432", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02432/input.txt", "sample_output_relpath": "derived/input_output/data/p02432/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02432/Kotlin/s183643988.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s183643988", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2\n1\n3\n4\n1\n", "input_to_evaluate": "\n\nfun main(args:Array):Unit {\n val vector = Vector()\n repeat(readLine()!!.toInt()){\n val arg = readLine()!!.split(' ').map(String::toInt)\n when(arg.first()){\n 0 -> when(arg[1]){\n 0 -> vector.pushFront(arg.last())\n else -> vector.pushBack(arg.last())\n }\n 1 -> println(vector[arg.last()])\n else -> when(arg[1]){\n 0 -> vector.popFront()\n else -> vector.popBack()\n }\n }\n }\n}\n\nclass Vector {\n var capacity:Int = 10000\n private set\n private var mHead:Int = 0//[mHead, mEnd)\n private var mEnd:Int = 0\n private var size:Int = 0\n private var mArray:Array = Array(10000){0}\n private fun resize():Unit {\n val newArray = Array(capacity * 2){0}\n for (i in 0 until size){\n newArray[i] = mArray[(i + mHead) % capacity]\n }\n capacity *= 2\n mHead = 0\n mEnd = size\n mArray = newArray\n }\n fun pushBack(value:Int):Unit {\n if (size == capacity) resize()\n mArray[mEnd] = value\n mEnd = (mEnd + 1) % capacity\n ++size\n }\n fun pushFront(value:Int):Unit {\n if (size == capacity) resize()\n mHead = (mHead + capacity - 1) % capacity\n mArray[mHead] = value\n ++size\n }\n fun popBack():Unit {\n mEnd = (mEnd + capacity - 1) % capacity\n }\n fun popFront():Unit {\n mHead = (mHead + 1) % capacity\n }\n operator fun get(index:Int):Int = mArray[(mHead + index) % capacity]\n}\n", "problem_context": "Deque\n\nFor a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:\n\npush($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.\n\nrandomAccess($p$): Print element $a_p$.\n\npop($d$): Delete the first element of $A$, if $d = 0$. Delete the last element of $A$, if $d = 1$.\n\n$A$ is a 0-origin array and it is empty in the initial state.\n\nInput\n\nThe input is given in the following format.\n\n$q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $d$ $x$\n\nor\n\n1 $p$\n\nor\n\n2 $d$\n\nwhere the first digits 0, 1 and 2 represent push, randomAccess and pop operations respectively.\n\nrandomAccess and pop operations will not be given for an empty array.\n\nOutput\n\nFor each randomAccess, print $a_p$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 400,000$\n\n$0 \\leq p < $ the size of $A$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 2\n2 0\n2 1\n0 0 4\n1 0\n1 1\n\nSample Output 1\n\n2\n1\n3\n4\n1", "sample_input": "11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 2\n2 0\n2 1\n0 0 4\n1 0\n1 1\n"}, "reference_outputs": ["2\n1\n3\n4\n1\n"], "source_document_id": "p02432", "source_text": "Deque\n\nFor a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:\n\npush($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.\n\nrandomAccess($p$): Print element $a_p$.\n\npop($d$): Delete the first element of $A$, if $d = 0$. Delete the last element of $A$, if $d = 1$.\n\n$A$ is a 0-origin array and it is empty in the initial state.\n\nInput\n\nThe input is given in the following format.\n\n$q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $d$ $x$\n\nor\n\n1 $p$\n\nor\n\n2 $d$\n\nwhere the first digits 0, 1 and 2 represent push, randomAccess and pop operations respectively.\n\nrandomAccess and pop operations will not be given for an empty array.\n\nOutput\n\nFor each randomAccess, print $a_p$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 400,000$\n\n$0 \\leq p < $ the size of $A$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 2\n2 0\n2 1\n0 0 4\n1 0\n1 1\n\nSample Output 1\n\n2\n1\n3\n4\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1577, "cpu_time_ms": 1250, "memory_kb": 142340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s637310505", "group_id": "codeNet:p02435", "input_text": "\nfun main(args:Array):Unit {\n val (n, q) = readLine()!!.split(' ').map(String::toInt)\n val stacks = Array(n){Stack()}\n repeat(q){\n val query = readLine()!!.split(' ').map(String::toInt)\n when(query.first()){\n 0 -> stacks[query[1]].push(query.last())\n 1 -> if (stacks[query.last()].isNotEmpty) println(stacks[query.last()].top())\n else -> stacks[query.last()].pop()\n }\n }\n}\n\nsealed class ImmutableList{\n object Nil:ImmutableList()\n data class Cons(val head:T, val tail:ImmutableList):ImmutableList()\n}\nclass Stack{\n private var mStack:ImmutableList = ImmutableList.Nil\n fun push(value:T):Unit {\n mStack = ImmutableList.Cons(value, mStack)\n }\n fun top():T = (mStack as ImmutableList.Cons).head\n fun pop():Unit {\n mStack = (mStack as ImmutableList.Cons).tail\n }\n val isEmpty:Boolean\n get() = mStack == ImmutableList.Nil\n val isNotEmpty:Boolean\n get() = !isEmpty\n}\n", "language": "Kotlin", "metadata": {"date": 1528509031, "filename_ext": "kt", "original_language": "Kotlin", "problem_description_relpath": "problem_descriptions/p02435.html", "problem_id": "p02435", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02435/input.txt", "sample_output_relpath": "derived/input_output/data/p02435/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02435/Kotlin/s637310505.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s637310505", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3\n5\n2\n", "input_to_evaluate": "\nfun main(args:Array):Unit {\n val (n, q) = readLine()!!.split(' ').map(String::toInt)\n val stacks = Array(n){Stack()}\n repeat(q){\n val query = readLine()!!.split(' ').map(String::toInt)\n when(query.first()){\n 0 -> stacks[query[1]].push(query.last())\n 1 -> if (stacks[query.last()].isNotEmpty) println(stacks[query.last()].top())\n else -> stacks[query.last()].pop()\n }\n }\n}\n\nsealed class ImmutableList{\n object Nil:ImmutableList()\n data class Cons(val head:T, val tail:ImmutableList):ImmutableList()\n}\nclass Stack{\n private var mStack:ImmutableList = ImmutableList.Nil\n fun push(value:T):Unit {\n mStack = ImmutableList.Cons(value, mStack)\n }\n fun top():T = (mStack as ImmutableList.Cons).head\n fun pop():Unit {\n mStack = (mStack as ImmutableList.Cons).tail\n }\n val isEmpty:Boolean\n get() = mStack == ImmutableList.Nil\n val isNotEmpty:Boolean\n get() = !isEmpty\n}\n", "problem_context": "Stack\n\nStack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).\n\nFor $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.\n\npush($t$, $x$): Insert an integer $x$ to $S_t$.\n\ntop($t$): Report the value which should be deleted next from $S_t$. If $S_t$ is empty, do nothing.\n\npop($t$): Delete an element from $S_t$. If $S_t$ is empty, do nothing.\n\nIn the initial state, all stacks are empty.\n\nInput\n\nThe input is given in the following format.\n\n$n \\; q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $t$ $x$\n\nor\n\n1 $t$\n\nor\n\n2 $t$\n\nwhere the first digits 0, 1 and 2 represent push, top and pop operations respectively.\n\nOutput\n\nFor each top operation, print an integer in a line.\n\nConstraints\n\n$1 \\leq n \\leq 1,000$\n\n$1 \\leq q \\leq 200,000$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0\n\nSample Output 1\n\n3\n5\n2", "sample_input": "3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0\n"}, "reference_outputs": ["3\n5\n2\n"], "source_document_id": "p02435", "source_text": "Stack\n\nStack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).\n\nFor $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.\n\npush($t$, $x$): Insert an integer $x$ to $S_t$.\n\ntop($t$): Report the value which should be deleted next from $S_t$. If $S_t$ is empty, do nothing.\n\npop($t$): Delete an element from $S_t$. If $S_t$ is empty, do nothing.\n\nIn the initial state, all stacks are empty.\n\nInput\n\nThe input is given in the following format.\n\n$n \\; q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $t$ $x$\n\nor\n\n1 $t$\n\nor\n\n2 $t$\n\nwhere the first digits 0, 1 and 2 represent push, top and pop operations respectively.\n\nOutput\n\nFor each top operation, print an integer in a line.\n\nConstraints\n\n$1 \\leq n \\leq 1,000$\n\n$1 \\leq q \\leq 200,000$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0\n\nSample Output 1\n\n3\n5\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1033, "cpu_time_ms": 120, "memory_kb": 32080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s290808689", "group_id": "codeNet:p02536", "input_text": "import java.util.*\n\n\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val root = (1..m*2).map { sc.nextInt() }\n print(calc(n, m, root))\n}\n\n\nfun calc(n: Int, m: Int, root: List): Int {\n var muda = 0\n val bestroot = n - 1 // 最高効率\n val a = root.filterIndexed { index, i -> index % 2 == 0 }.distinct()\n val b = root.filterIndexed { index, i -> index % 2 == 1 }.distinct()\n val rootnum = if(a.size > b.size) a.size else b.size\n return bestroot - rootnum\n}", "language": "Kotlin", "metadata": {"date": 1601173779, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/Kotlin/s290808689.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s290808689", "user_id": "u440530959"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\n\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val root = (1..m*2).map { sc.nextInt() }\n print(calc(n, m, root))\n}\n\n\nfun calc(n: Int, m: Int, root: List): Int {\n var muda = 0\n val bestroot = n - 1 // 最高効率\n val a = root.filterIndexed { index, i -> index % 2 == 0 }.distinct()\n val b = root.filterIndexed { index, i -> index % 2 == 1 }.distinct()\n val rootnum = if(a.size > b.size) a.size else b.size\n return bestroot - rootnum\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 537, "cpu_time_ms": 681, "memory_kb": 66036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s786483175", "group_id": "codeNet:p02536", "input_text": "import java.util.*\n\n\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val root = (1..m*2).map { sc.nextInt() }\n print(calc(n, m, root))\n}\n\nfun calc(n: Int, m: Int, root: List): Int {\n val citylist = mutableListOf()\n var muda = 0\n val bestroot = n - 1 // 最高効率\n for(i in root.indices step 2) {\n if(!citylist.contains(root[i])) {\n citylist.add(i)\n }\n else {\n muda++\n }\n }\n return bestroot - m + muda\n}\n", "language": "Kotlin", "metadata": {"date": 1601172779, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/Kotlin/s786483175.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s786483175", "user_id": "u440530959"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\n\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val root = (1..m*2).map { sc.nextInt() }\n print(calc(n, m, root))\n}\n\nfun calc(n: Int, m: Int, root: List): Int {\n val citylist = mutableListOf()\n var muda = 0\n val bestroot = n - 1 // 最高効率\n for(i in root.indices step 2) {\n if(!citylist.contains(root[i])) {\n citylist.add(i)\n }\n else {\n muda++\n }\n }\n return bestroot - m + muda\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 541, "cpu_time_ms": 2208, "memory_kb": 66672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s354979708", "group_id": "codeNet:p02536", "input_text": "\n import kotlin.math.*\n import java.io.BufferedReader\n import java.io.InputStreamReader\n import java.util.*\n\n\n private var fs = BufferedReader(InputStreamReader(System.`in`))\n private fun readLn() = fs.readLine()!!\n private fun readStrings() = readLn().split(\" \")\n private fun readLong() = readLn().toLong()\n private fun readLongs() = readStrings().map { it.toLong() }\n private fun readInt() = readLn().toInt()\n private fun readInts() = readStrings().map { it.toInt() }\n fun main() {\n // val t = readInt()\n // for (tt in 0 until t) {\n solveA()\n // }\n }\n fun solveA() {\n var (N,M) = readInts()\n var arr = ArrayList>()\n var connectTo = 0\n var cnt = N\n loop@for (i in 1..M) {\n var (a,b) = readInts()\n for(j in arr){\n if (j.contains(a) || j.contains(b)) {\n j.add(a)\n j.add(b)\n cnt--\n continue@loop\n }\n }\n arr.add(hashSetOf(a,b))\n cnt -= 2\n }\n var ans = arr.size - 1 + cnt\n println(ans)\n }\n\n", "language": "Kotlin", "metadata": {"date": 1601170834, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/Kotlin/s354979708.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s354979708", "user_id": "u843609965"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\n import kotlin.math.*\n import java.io.BufferedReader\n import java.io.InputStreamReader\n import java.util.*\n\n\n private var fs = BufferedReader(InputStreamReader(System.`in`))\n private fun readLn() = fs.readLine()!!\n private fun readStrings() = readLn().split(\" \")\n private fun readLong() = readLn().toLong()\n private fun readLongs() = readStrings().map { it.toLong() }\n private fun readInt() = readLn().toInt()\n private fun readInts() = readStrings().map { it.toInt() }\n fun main() {\n // val t = readInt()\n // for (tt in 0 until t) {\n solveA()\n // }\n }\n fun solveA() {\n var (N,M) = readInts()\n var arr = ArrayList>()\n var connectTo = 0\n var cnt = N\n loop@for (i in 1..M) {\n var (a,b) = readInts()\n for(j in arr){\n if (j.contains(a) || j.contains(b)) {\n j.add(a)\n j.add(b)\n cnt--\n continue@loop\n }\n }\n arr.add(hashSetOf(a,b))\n cnt -= 2\n }\n var ans = arr.size - 1 + cnt\n println(ans)\n }\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1190, "cpu_time_ms": 2208, "memory_kb": 73748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s541652918", "group_id": "codeNet:p02541", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readLong()\n\n var ans = Long.MAX_VALUE\n\n (n + n).forEachDivisor run@{ x ->\n val y = (n + n) / x\n if (y == 1L) return@run\n\n val a = x.modInvOrElse(y) { return@run }\n val r = (y - a) * x\n ans = min(ans, r)\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ninfix fun Int.divCeil(other: Int) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\ninline infix fun Int.divFloor(other: Int) = Math.floorDiv(this, other)\n\ninfix fun Long.divCeil(other: Long) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\ninline infix fun Long.divCeil(other: Int) = divCeil(other.toLong())\n\ninline infix fun Long.divFloor(other: Long) = Math.floorDiv(this, other)\n\n// floor and ceiling multiples, named by analogy with Excel's MROUND\ninfix fun Int.mCeil(m: Int) = divCeil(m) * m\ninfix fun Int.mFloor(m: Int) = divFloor(m) * m\ninfix fun Long.mCeil(m: Long) = divCeil(m) * m\ninfix fun Long.mFloor(m: Long) = divFloor(m) * m\n\ninline fun Long.modInvOrElse(base: Long, default: () -> Long): Long {\n var s = 0L\n var os = 1L\n var r = base\n var or = this % base\n\n while(r != 0L) {\n val q = or / r\n or = r.also { r = or - q * r }\n os = s.also { s = os - q * s }\n }\n\n return if(or != 1L) default()\n else os.let { if(it >= 0) it else it + base }\n}\n\ninline fun Long.forEachDivisor(yield: (Long) -> Unit) {\n if(this <= 0) return\n val tail = LongList()\n\n for(p in 1..this) {\n val sq = p * p\n if(sq > this) break\n if(this % p == 0L) {\n yield(p)\n if(sq != this) tail.add(this / p)\n }\n }\n\n for(i in tail.lastIndex downTo 0) yield(tail[i])\n}\n\nclass LongList(initialCapacity: Int = 12) {\n private var _arr = LongArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: LongArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toLongArray(); size = copyFrom.size }\n\n fun contentEquals(other: LongList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Long {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Long) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Long) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: LongList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Long) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Long {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Long): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Long): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: LongIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextLong() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toLongArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun LongList(size: Int, init: (Int) -> Long) = LongList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun LongArray.toLongList() = LongList(this)\ninline fun Collection.toLongList() = LongList(this)\ninline fun longListOf(vararg values: Long) = LongList(values)\n\nfun LongList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun LongList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun LongList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun LongList.count(predicate: (Long) -> Boolean) = indices.count { predicate(this[it]) }\nfun LongList.copyOf() = LongList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1600647703, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02541.html", "problem_id": "p02541", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02541/input.txt", "sample_output_relpath": "derived/input_output/data/p02541/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02541/Kotlin/s541652918.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s541652918", "user_id": "u596111103"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readLong()\n\n var ans = Long.MAX_VALUE\n\n (n + n).forEachDivisor run@{ x ->\n val y = (n + n) / x\n if (y == 1L) return@run\n\n val a = x.modInvOrElse(y) { return@run }\n val r = (y - a) * x\n ans = min(ans, r)\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ninfix fun Int.divCeil(other: Int) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\ninline infix fun Int.divFloor(other: Int) = Math.floorDiv(this, other)\n\ninfix fun Long.divCeil(other: Long) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\ninline infix fun Long.divCeil(other: Int) = divCeil(other.toLong())\n\ninline infix fun Long.divFloor(other: Long) = Math.floorDiv(this, other)\n\n// floor and ceiling multiples, named by analogy with Excel's MROUND\ninfix fun Int.mCeil(m: Int) = divCeil(m) * m\ninfix fun Int.mFloor(m: Int) = divFloor(m) * m\ninfix fun Long.mCeil(m: Long) = divCeil(m) * m\ninfix fun Long.mFloor(m: Long) = divFloor(m) * m\n\ninline fun Long.modInvOrElse(base: Long, default: () -> Long): Long {\n var s = 0L\n var os = 1L\n var r = base\n var or = this % base\n\n while(r != 0L) {\n val q = or / r\n or = r.also { r = or - q * r }\n os = s.also { s = os - q * s }\n }\n\n return if(or != 1L) default()\n else os.let { if(it >= 0) it else it + base }\n}\n\ninline fun Long.forEachDivisor(yield: (Long) -> Unit) {\n if(this <= 0) return\n val tail = LongList()\n\n for(p in 1..this) {\n val sq = p * p\n if(sq > this) break\n if(this % p == 0L) {\n yield(p)\n if(sq != this) tail.add(this / p)\n }\n }\n\n for(i in tail.lastIndex downTo 0) yield(tail[i])\n}\n\nclass LongList(initialCapacity: Int = 12) {\n private var _arr = LongArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: LongArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toLongArray(); size = copyFrom.size }\n\n fun contentEquals(other: LongList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Long {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Long) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Long) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: LongList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Long) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Long {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n fun indexOf(e: Long): Int {\n for(i in 0 until size) if(this[i] == e) return i\n return -1\n }\n\n fun remove(e: Long): Boolean {\n val i = indexOf(e)\n if(i == -1) return false\n removeAt(i)\n return true\n }\n\n operator fun iterator() = object: LongIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextLong() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) {\n require(s >= 0)\n if(s < size) size = s\n }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toLongArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun LongList(size: Int, init: (Int) -> Long) = LongList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun LongArray.toLongList() = LongList(this)\ninline fun Collection.toLongList() = LongList(this)\ninline fun longListOf(vararg values: Long) = LongList(values)\n\nfun LongList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun LongList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun LongList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun LongList.count(predicate: (Long) -> Boolean) = indices.count { predicate(this[it]) }\nfun LongList.copyOf() = LongList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer N.\nFind the minimum possible positive integer k such that (1+2+\\cdots+k) is a multiple of N.\nIt can be proved that such a positive integer k always exists.\n\nConstraints\n\n1 \\leq N \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer in a line.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n10\n\n1+2+\\cdots+10=55 holds and 55 is indeed a multple of N=11.\nThere are no positive integers k \\leq 9 that satisfy the condition, so the answer is k = 10.\n\nSample Input 2\n\n20200920\n\nSample Output 2\n\n1100144", "sample_input": "11\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02541", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer N.\nFind the minimum possible positive integer k such that (1+2+\\cdots+k) is a multiple of N.\nIt can be proved that such a positive integer k always exists.\n\nConstraints\n\n1 \\leq N \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer in a line.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n10\n\n1+2+\\cdots+10=55 holds and 55 is indeed a multple of N=11.\nThere are no positive integers k \\leq 9 that satisfy the condition, so the answer is k = 10.\n\nSample Input 2\n\n20200920\n\nSample Output 2\n\n1100144", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9953, "cpu_time_ms": 522, "memory_kb": 35396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s568773228", "group_id": "codeNet:p02547", "input_text": "fun main(args: Array) {\n val n: Int = readLine()!!.toInt()\n val list: MutableList> = mutableListOf()\n for (i in 1..n) {\n list.add(readLine()!!.split(\" \").map { it.toInt() })\n }\n var answer: String = \"No\"\n for (i in 0..list.size - 3) {\n var one: Boolean = false\n var two: Boolean = false\n var three: Boolean = false\n if (list[i][0] == list[i][1]) one = true\n if (list[i + 1][0] == list[i + 1][1]) two = true\n if (list[i + 2][0] == list[i + 2][1]) three = true\n if (one && two && three) {\n answer = \"Yes\"\n break\n }\n }\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1600543677, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02547/input.txt", "sample_output_relpath": "derived/input_output/data/p02547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02547/Kotlin/s568773228.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568773228", "user_id": "u980534023"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n: Int = readLine()!!.toInt()\n val list: MutableList> = mutableListOf()\n for (i in 1..n) {\n list.add(readLine()!!.split(\" \").map { it.toInt() })\n }\n var answer: String = \"No\"\n for (i in 0..list.size - 3) {\n var one: Boolean = false\n var two: Boolean = false\n var three: Boolean = false\n if (list[i][0] == list[i][1]) one = true\n if (list[i + 1][0] == list[i + 1][1]) two = true\n if (list[i + 2][0] == list[i + 2][1]) three = true\n if (one && two && three) {\n answer = \"Yes\"\n break\n }\n }\n println(answer)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 137, "memory_kb": 37860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s035938059", "group_id": "codeNet:p02547", "input_text": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val n = readInt()\n val arr1 = mutableListOf()\n val arr2 = mutableListOf()\n\n repeat(n) {\n val (a1, a2) = readInts()\n\n arr1.add(a1)\n arr2.add(a2)\n }\n\n var doubletFound = false\n var doubletCount = 0\n repeat(n) { i ->\n if (arr1[i] == arr2[i]) {\n if (++doubletCount == 3) doubletFound = true\n } else {\n doubletCount = 0\n }\n }\n\n if (doubletFound) println(\"Yes\")\n else println(\"No\")\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints", "language": "Kotlin", "metadata": {"date": 1600542842, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02547/input.txt", "sample_output_relpath": "derived/input_output/data/p02547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02547/Kotlin/s035938059.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035938059", "user_id": "u448586208"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nfun main() {\n solve()\n}\n\nprivate fun solve() {\n val n = readInt()\n val arr1 = mutableListOf()\n val arr2 = mutableListOf()\n\n repeat(n) {\n val (a1, a2) = readInts()\n\n arr1.add(a1)\n arr2.add(a2)\n }\n\n var doubletFound = false\n var doubletCount = 0\n repeat(n) { i ->\n if (arr1[i] == arr2[i]) {\n if (++doubletCount == 3) doubletFound = true\n } else {\n doubletCount = 0\n }\n }\n\n if (doubletFound) println(\"Yes\")\n else println(\"No\")\n}\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map { it.toInt() } // list of ints", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 784, "cpu_time_ms": 134, "memory_kb": 37952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s092639973", "group_id": "codeNet:p02548", "input_text": "import kotlin.math.sqrt\n\nfun main(args: Array) {\n val n: Int = readLine()!!.toInt()\n val memo: MutableList = mutableListOf()\n for (i in 1..n - 1) {\n memo.add(calc(i))\n }\n println(memo.sum())\n}\n\nfun calc(i: Int): Int {\n var answer = 0\n val n = sqrt(i.toDouble()).toInt()\n\n for (j in 1..n) {\n if (i % j == 0) {\n answer += 1\n }\n }\n if (i == n * n) {\n answer = answer * 2 - 1\n } else {\n answer = answer * 2\n }\n return answer\n}", "language": "Kotlin", "metadata": {"date": 1600546101, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02548.html", "problem_id": "p02548", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02548/input.txt", "sample_output_relpath": "derived/input_output/data/p02548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02548/Kotlin/s092639973.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092639973", "user_id": "u980534023"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import kotlin.math.sqrt\n\nfun main(args: Array) {\n val n: Int = readLine()!!.toInt()\n val memo: MutableList = mutableListOf()\n for (i in 1..n - 1) {\n memo.add(calc(i))\n }\n println(memo.sum())\n}\n\nfun calc(i: Int): Int {\n var answer = 0\n val n = sqrt(i.toDouble()).toInt()\n\n for (j in 1..n) {\n if (i % j == 0) {\n answer += 1\n }\n }\n if (i == n * n) {\n answer = answer * 2 - 1\n } else {\n answer = answer * 2\n }\n return answer\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 468, "cpu_time_ms": 1809, "memory_kb": 56108}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s310739212", "group_id": "codeNet:p02549", "input_text": "fun main() {\n val (n, K) = readLine()!!.split(\" \").map { it.toInt() }\n val s = Array(K) {\n readLine()!!.split(\" \").map { it.toInt() }.let {\n Pair(it[0], it[1])\n }\n }\n\n val mod = 998244353L\n\n val dp = MutableList(n + 1) { 0L }\n val dpSum = MutableList(n + 1) { 0L }\n dp[1] = 1L\n\n for (i in 1 until n + 1) {\n for ((l, r) in s) {\n dp[i] = dp[i] % mod + ((if ((i - l) > 0) dpSum[i - l] else 0) % mod - (if ((i - r - 1) > 0) dpSum[i - r - 1] else 0) % mod) % mod\n }\n dpSum[i] = (dpSum[i - 1] + dp[i]) % mod\n }\n println(dp[n] % mod)\n}\n", "language": "Kotlin", "metadata": {"date": 1600602769, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02549.html", "problem_id": "p02549", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02549/input.txt", "sample_output_relpath": "derived/input_output/data/p02549/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02549/Kotlin/s310739212.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s310739212", "user_id": "u692054751"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val (n, K) = readLine()!!.split(\" \").map { it.toInt() }\n val s = Array(K) {\n readLine()!!.split(\" \").map { it.toInt() }.let {\n Pair(it[0], it[1])\n }\n }\n\n val mod = 998244353L\n\n val dp = MutableList(n + 1) { 0L }\n val dpSum = MutableList(n + 1) { 0L }\n dp[1] = 1L\n\n for (i in 1 until n + 1) {\n for ((l, r) in s) {\n dp[i] = dp[i] % mod + ((if ((i - l) > 0) dpSum[i - l] else 0) % mod - (if ((i - r - 1) > 0) dpSum[i - r - 1] else 0) % mod) % mod\n }\n dpSum[i] = (dpSum[i - 1] + dp[i]) % mod\n }\n println(dp[n] % mod)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "sample_input": "5 2\n1 1\n3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02549", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 616, "cpu_time_ms": 365, "memory_kb": 68556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s530625988", "group_id": "codeNet:p02549", "input_text": "import java.util.*\nimport kotlin.math.*\n\nfun main() {\n val mod = 998244353L\n\n val (n, k) = readIntList()\n val range = List(k) { readIntList() }\n\n val dp = LongArray(n + 1)\n val dpSum = LongArray(n + 1)\n dp[1] = 1L\n dpSum[1] = 1L\n\n for (i in 2..n) {\n for ((l, r) in range) {\n val li = max(i - r, 1)\n val ri = i - l\n if (ri < 0) continue\n dp[i] += (dpSum[ri] - dpSum[li - 1]) % mod\n }\n dpSum[i] = (dpSum[i - 1] + dp[i]) % mod\n }\n println(dp[n])\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1600598264, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02549.html", "problem_id": "p02549", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02549/input.txt", "sample_output_relpath": "derived/input_output/data/p02549/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02549/Kotlin/s530625988.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s530625988", "user_id": "u697467902"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.*\n\nfun main() {\n val mod = 998244353L\n\n val (n, k) = readIntList()\n val range = List(k) { readIntList() }\n\n val dp = LongArray(n + 1)\n val dpSum = LongArray(n + 1)\n dp[1] = 1L\n dpSum[1] = 1L\n\n for (i in 2..n) {\n for ((l, r) in range) {\n val li = max(i - r, 1)\n val ri = i - l\n if (ri < 0) continue\n dp[i] += (dpSum[ri] - dpSum[li - 1]) % mod\n }\n dpSum[i] = (dpSum[i - 1] + dp[i]) % mod\n }\n println(dp[n])\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "sample_input": "5 2\n1 1\n3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02549", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 823, "cpu_time_ms": 201, "memory_kb": 48452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s377239390", "group_id": "codeNet:p02552", "input_text": "fun main() {\n println((readInt() + 1) % 2)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()\n", "language": "Kotlin", "metadata": {"date": 1600023681, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/Kotlin/s377239390.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s377239390", "user_id": "u984465701"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "fun main() {\n println((readInt() + 1) % 2)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 143, "cpu_time_ms": 107, "memory_kb": 34444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s108215012", "group_id": "codeNet:p02553", "input_text": "fun main(args: Array) {\n val (a, b, c, d) = readLine()!!.split(' ').map { it.toLong() }\n\n val min1 = Math.min(a, b)\n val max1 = Math.max(a, b)\n\n val min2 = Math.min(c, d)\n val max2 = Math.max(c, d)\n\n when {\n // + +\n max1 > 0 && max2 > 0 -> {\n println(max1 * max2)\n }\n // + -\n max1 > 0 && max2 < 0 -> {\n println(max1 * min2)\n }\n\n // - +\n max1 < 0 && max2 > 0 -> {\n println(min1 * max2)\n }\n // - -\n max1 <= 0 && max2 <= 0 -> {\n println(min1 * min2)\n }\n else -> {\n println(0)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1600025909, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/Kotlin/s108215012.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s108215012", "user_id": "u366280250"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c, d) = readLine()!!.split(' ').map { it.toLong() }\n\n val min1 = Math.min(a, b)\n val max1 = Math.max(a, b)\n\n val min2 = Math.min(c, d)\n val max2 = Math.max(c, d)\n\n when {\n // + +\n max1 > 0 && max2 > 0 -> {\n println(max1 * max2)\n }\n // + -\n max1 > 0 && max2 < 0 -> {\n println(max1 * min2)\n }\n\n // - +\n max1 < 0 && max2 > 0 -> {\n println(min1 * max2)\n }\n // - -\n max1 <= 0 && max2 <= 0 -> {\n println(min1 * min2)\n }\n else -> {\n println(0)\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 663, "cpu_time_ms": 127, "memory_kb": 36400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s066027126", "group_id": "codeNet:p02553", "input_text": "import java.io.BufferedReader\nimport java.io.BufferedWriter\n\nfun main() = Case().exec(::solve)\n//fun main() = TestExecutor.assert(testCase) { Case(it.r, it.w).exec(::solve) }\n\n/** https://atcoder.jp/contests/abc178/tasks/abc178_b **/\nfun solve(case: Case) {\n val (a, b, c, d) = case.longList()\n case.println(listOf(a * c, a * d, b * c, b * d).max()!!.toString())\n}\n\nclass Case(\n private val input: BufferedReader = System.`in`.bufferedReader(),\n private val out: BufferedWriter = System.out.bufferedWriter()\n) {\n fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }\n private fun execInThread(fn: (Case) -> Unit) =\n Thread(null, { fn(this) }, \"solve\", 64 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }\n .apply { start() }.join()\n\n fun println(c: CharSequence?) = out.appendln(c)\n fun string(): String = input.readLine().trimEnd()\n fun long(): Long = input.readLine().toLong()\n fun intList(): List = input.readLine().split(\" \").map { it.toInt() }\n fun longList(): List = input.readLine().split(\" \").map { it.toLong() }\n}", "language": "Kotlin", "metadata": {"date": 1600023910, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/Kotlin/s066027126.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066027126", "user_id": "u843036991"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.BufferedWriter\n\nfun main() = Case().exec(::solve)\n//fun main() = TestExecutor.assert(testCase) { Case(it.r, it.w).exec(::solve) }\n\n/** https://atcoder.jp/contests/abc178/tasks/abc178_b **/\nfun solve(case: Case) {\n val (a, b, c, d) = case.longList()\n case.println(listOf(a * c, a * d, b * c, b * d).max()!!.toString())\n}\n\nclass Case(\n private val input: BufferedReader = System.`in`.bufferedReader(),\n private val out: BufferedWriter = System.out.bufferedWriter()\n) {\n fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }\n private fun execInThread(fn: (Case) -> Unit) =\n Thread(null, { fn(this) }, \"solve\", 64 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }\n .apply { start() }.join()\n\n fun println(c: CharSequence?) = out.appendln(c)\n fun string(): String = input.readLine().trimEnd()\n fun long(): Long = input.readLine().toLong()\n fun intList(): List = input.readLine().split(\" \").map { it.toInt() }\n fun longList(): List = input.readLine().split(\" \").map { it.toLong() }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1182, "cpu_time_ms": 139, "memory_kb": 39284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s330265796", "group_id": "codeNet:p02554", "input_text": "//\n\nfun main() {\n abc178c()\n}\n\nfun abc178c() {\n val n = readLine()!!.toInt()\n var count = 2L\n repeat(n - 1) {\n count = (count * count) % 1_000_000_007L\n }\n count -= 2\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1600024621, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02554/input.txt", "sample_output_relpath": "derived/input_output/data/p02554/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02554/Kotlin/s330265796.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s330265796", "user_id": "u628907033"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//\n\nfun main() {\n abc178c()\n}\n\nfun abc178c() {\n val n = readLine()!!.toInt()\n var count = 2L\n repeat(n - 1) {\n count = (count * count) % 1_000_000_007L\n }\n count -= 2\n println(count)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "sample_input": "2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02554", "source_text": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 213, "cpu_time_ms": 114, "memory_kb": 34604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s961799860", "group_id": "codeNet:p02555", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readInt()\n\n val dp = LongArray(2005){0}\n for (i in 0 until 3) {\n dp[i] = 0\n }\n for (i in 3 until 6) {\n dp[i] = 1\n }\n\n for (i in 6 .. S) {\n dp[i] += dp[i-3]\n dp[i] %= MOD\n dp[i] += dp[i-1]\n dp[i] %= MOD\n }\n\n val ans = dp[S]\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"178\", \"d\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readDouble: () -> Double = { br.readLine().toDouble() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntArray: () -> IntArray = { readListInt().toIntArray() }\n val readLongArray: () -> LongArray = { readListLong().toLongArray() }\n val readListStringCol: (Int) -> List = { N -> (0 until N).map { readString() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { readListInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { readListLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1600027292, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02555.html", "problem_id": "p02555", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02555/input.txt", "sample_output_relpath": "derived/input_output/data/p02555/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02555/Kotlin/s961799860.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s961799860", "user_id": "u404244809"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val S = rd.readInt()\n\n val dp = LongArray(2005){0}\n for (i in 0 until 3) {\n dp[i] = 0\n }\n for (i in 3 until 6) {\n dp[i] = 1\n }\n\n for (i in 6 .. S) {\n dp[i] += dp[i-3]\n dp[i] %= MOD\n dp[i] += dp[i-1]\n dp[i] %= MOD\n }\n\n val ans = dp[S]\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"178\", \"d\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readDouble: () -> Double = { br.readLine().toDouble() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntArray: () -> IntArray = { readListInt().toIntArray() }\n val readLongArray: () -> LongArray = { readListLong().toLongArray() }\n val readListStringCol: (Int) -> List = { N -> (0 until N).map { readString() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { readListInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { readListLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq S \\leq 2000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n3\n\n3 sequences satisfy the condition: \\{3,4\\}, \\{4,3\\} and \\{7\\}.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nThere are no sequences that satisfy the condition.\n\nSample Input 3\n\n1729\n\nSample Output 3\n\n294867501", "sample_input": "7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02555", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq S \\leq 2000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n3\n\n3 sequences satisfy the condition: \\{3,4\\}, \\{4,3\\} and \\{7\\}.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nThere are no sequences that satisfy the condition.\n\nSample Input 3\n\n1729\n\nSample Output 3\n\n294867501", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2906, "cpu_time_ms": 110, "memory_kb": 34744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s371507075", "group_id": "codeNet:p02556", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\n\nfun main(args: Array) {\n\n // IO Templates\n val br = BufferedReader(InputStreamReader(System.`in`))\n val out = PrintWriter(System.out)\n\n val n = br.readLine()!!.toInt()\n\n val points = mutableListOf()\n\n for (i in 1..n) {\n val (x, y) = br.readLine()!!.split(' ').map { it.toInt() }\n points.add(MyVector(x, y))\n }\n\n var ru = points.first()\n var lu = points.first()\n var ld = points.first()\n var rd = points.first()\n\n for (i in 1 until n) {\n val point = points[i]\n if ((point.x - ru.x) + (point.y - ru.y) > 0) ru = point\n if ((-point.x + lu.x) + (point.y - lu.y) > 0) lu = point\n if ((-point.x + ld.x) + (-point.y + ld.y) > 0) ld = point\n if ((point.x - rd.x) + (-point.y + rd.y) > 0) rd = point\n }\n\n out.println(\n max(\n abs(ru.x - ld.x) + abs(ru.y - ld.y),\n abs(lu.x - rd.x) + abs(lu.y - rd.y)\n )\n )\n\n out.flush()\n}\n\ndata class MyVector(\n var x: Long,\n var y: Long\n) {\n\n constructor(x: Int, y: Int) : this(x = x.toLong(), y = y.toLong())\n\n fun plus(x: Long, y: Long) {\n this.x += x\n this.y += y\n }\n\n operator fun plus(v: MyVector) {\n plus(v.x, v.y)\n }\n\n fun minus(x: Long, y: Long) {\n this.x -= x\n this.y -= y\n }\n\n operator fun minus(v: MyVector) {\n minus(v.x, v.y)\n }\n\n fun scalarTimes(m: Long) {\n x *= m\n y *= m\n }\n\n operator fun times(v: MyVector): Long = x * v.x + y * v.y\n\n fun squareMagnitude(): Long = this.times(this)\n\n fun magnitude(): Double = sqrt(squareMagnitude().toDouble())\n}\n", "language": "Kotlin", "metadata": {"date": 1600520915, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/Kotlin/s371507075.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371507075", "user_id": "u756514276"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\n\nfun main(args: Array) {\n\n // IO Templates\n val br = BufferedReader(InputStreamReader(System.`in`))\n val out = PrintWriter(System.out)\n\n val n = br.readLine()!!.toInt()\n\n val points = mutableListOf()\n\n for (i in 1..n) {\n val (x, y) = br.readLine()!!.split(' ').map { it.toInt() }\n points.add(MyVector(x, y))\n }\n\n var ru = points.first()\n var lu = points.first()\n var ld = points.first()\n var rd = points.first()\n\n for (i in 1 until n) {\n val point = points[i]\n if ((point.x - ru.x) + (point.y - ru.y) > 0) ru = point\n if ((-point.x + lu.x) + (point.y - lu.y) > 0) lu = point\n if ((-point.x + ld.x) + (-point.y + ld.y) > 0) ld = point\n if ((point.x - rd.x) + (-point.y + rd.y) > 0) rd = point\n }\n\n out.println(\n max(\n abs(ru.x - ld.x) + abs(ru.y - ld.y),\n abs(lu.x - rd.x) + abs(lu.y - rd.y)\n )\n )\n\n out.flush()\n}\n\ndata class MyVector(\n var x: Long,\n var y: Long\n) {\n\n constructor(x: Int, y: Int) : this(x = x.toLong(), y = y.toLong())\n\n fun plus(x: Long, y: Long) {\n this.x += x\n this.y += y\n }\n\n operator fun plus(v: MyVector) {\n plus(v.x, v.y)\n }\n\n fun minus(x: Long, y: Long) {\n this.x -= x\n this.y -= y\n }\n\n operator fun minus(v: MyVector) {\n minus(v.x, v.y)\n }\n\n fun scalarTimes(m: Long) {\n x *= m\n y *= m\n }\n\n operator fun times(v: MyVector): Long = x * v.x + y * v.y\n\n fun squareMagnitude(): Long = this.times(this)\n\n fun magnitude(): Double = sqrt(squareMagnitude().toDouble())\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1803, "cpu_time_ms": 418, "memory_kb": 64760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163847940", "group_id": "codeNet:p02556", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val N = rd.readInt()\n val XY = rd.readListIntCols(N)\n\n val A = Array(N){IntPair(0,0)}\n for (i in 0 until N) {\n A[i] = IntPair(XY[i][0], XY[i][1])\n }\n\n val DX = A.sortedBy { it.first }\n val DY = A.sortedBy { it.second }\n\n val ans = max(\n abs(DX[N-1].first-DX[0].first) + abs(DX[N-1].second-DX[0].second),\n abs(DY[N-1].first-DY[0].first) + abs(DY[N-1].second-DY[0].second)\n )\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"178\", \"e\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readDouble: () -> Double = { br.readLine().toDouble() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntArray: () -> IntArray = { readListInt().toIntArray() }\n val readLongArray: () -> LongArray = { readListLong().toLongArray() }\n val readListStringCol: (Int) -> List = { N -> (0 until N).map { readString() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { readListInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { readListLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1600028588, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/Kotlin/s163847940.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s163847940", "user_id": "u404244809"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val N = rd.readInt()\n val XY = rd.readListIntCols(N)\n\n val A = Array(N){IntPair(0,0)}\n for (i in 0 until N) {\n A[i] = IntPair(XY[i][0], XY[i][1])\n }\n\n val DX = A.sortedBy { it.first }\n val DY = A.sortedBy { it.second }\n\n val ans = max(\n abs(DX[N-1].first-DX[0].first) + abs(DX[N-1].second-DX[0].second),\n abs(DY[N-1].first-DY[0].first) + abs(DY[N-1].second-DY[0].second)\n )\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"178\", \"e\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readDouble: () -> Double = { br.readLine().toDouble() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntArray: () -> IntArray = { readListInt().toIntArray() }\n val readLongArray: () -> LongArray = { readListLong().toLongArray() }\n val readListStringCol: (Int) -> List = { N -> (0 until N).map { readString() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { readListInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { readListLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3033, "cpu_time_ms": 1308, "memory_kb": 88584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s850290560", "group_id": "codeNet:p02556", "input_text": "import kotlin.math.abs\nimport kotlin.math.max\n\nfun main() {\n val n = nextInt()\n val points = (0 until n).map {\n val (x, y) = nextIntList()\n x to y\n }\n val x = points.sortedBy { it.first }\n val y = points.sortedBy { it.second }\n\n var m = 0\n x.forEach { pair ->\n val x0 = x[0]\n val xl = x.last()\n m = max(\n m, max(\n abs(x0.first - pair.first) + abs(x0.second - pair.second),\n abs(xl.first - pair.first) + abs(xl.second - pair.second)\n )\n )\n }\n y.forEach { pair ->\n val y0 = y[0]\n val yl = y.last()\n m = max(\n m, max(\n abs(y0.first - pair.first) + abs(y0.second - pair.second),\n abs(yl.first - pair.first) + abs(yl.second - pair.second)\n )\n )\n }\n println(m)\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n\nfun gcd(x: Int, y: Int): Int {\n fun innerGcd(x: Int, y: Int): Int {\n return if (x % y == 0) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\nfun gcd(x: Long, y: Long): Long {\n fun innerGcd(x: Long, y: Long): Long {\n return if (x % y == 0L) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n", "language": "Kotlin", "metadata": {"date": 1600028044, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/Kotlin/s850290560.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s850290560", "user_id": "u885556801"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.max\n\nfun main() {\n val n = nextInt()\n val points = (0 until n).map {\n val (x, y) = nextIntList()\n x to y\n }\n val x = points.sortedBy { it.first }\n val y = points.sortedBy { it.second }\n\n var m = 0\n x.forEach { pair ->\n val x0 = x[0]\n val xl = x.last()\n m = max(\n m, max(\n abs(x0.first - pair.first) + abs(x0.second - pair.second),\n abs(xl.first - pair.first) + abs(xl.second - pair.second)\n )\n )\n }\n y.forEach { pair ->\n val y0 = y[0]\n val yl = y.last()\n m = max(\n m, max(\n abs(y0.first - pair.first) + abs(y0.second - pair.second),\n abs(yl.first - pair.first) + abs(yl.second - pair.second)\n )\n )\n }\n println(m)\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\ninline fun sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }\n\n// ## mod^-1\n// [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)\nfun modinv(num: Long, mod: Long): Long {\n var a = num\n var b = mod\n var u = 1L\n var v = 0L\n while (b > 0) {\n val t = a.div(b)\n a -= t * b\n a = b.also { b = a } // swap a and b\n u -= t * v\n u = v.also { v = u } // swap u and v\n }\n u %= mod\n if (u < 0) u += mod\n return u\n}\n\nfun gcd(x: Int, y: Int): Int {\n fun innerGcd(x: Int, y: Int): Int {\n return if (x % y == 0) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n\nfun gcd(x: Long, y: Long): Long {\n fun innerGcd(x: Long, y: Long): Long {\n return if (x % y == 0L) y else innerGcd(y, x % y)\n }\n return if (x >= y) innerGcd(x, y) else innerGcd(y, x)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2260, "cpu_time_ms": 1592, "memory_kb": 78748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s397223654", "group_id": "codeNet:p02557", "input_text": "fun main() {\n val n = readInt()\n val a = readInts()\n val b = readInts()\n\n val occA = mutableListOf()\n val occB = mutableListOf()\n\n fun fillOcc(arr: List, occArr: MutableList, index: Int) {\n if (occArr.isEmpty() || occArr.last().number != arr[index]) occArr.add(Occurrences(index, arr[index], 0))\n occArr.last().occ++\n }\n\n for (i in 0 until n) {\n fillOcc(a, occA, i)\n fillOcc(b, occB, i)\n }\n\n occA.sortBy { it.occ }\n occB.sortBy { it.occ }\n\n var aIndex = occA.size - 1\n var bIndex = if (occB[occB.size - 1].number == occA[aIndex].number) occB.size - 2 else occB.size - 1\n if (bIndex < 0) {\n println(\"No\")\n return\n }\n val seenA = mutableSetOf()\n val seenB = mutableSetOf()\n\n val reordering = IntArray(n)\n while (seenA.size < occA.size && seenB.size < occB.size) {\n val currA = occA[aIndex]\n val currB = occB[bIndex]\n reordering[currA.startIndex] = currB.number\n currA.startIndex++\n currA.occ--\n currB.startIndex++\n currB.occ--\n if (currA.occ == 0) {\n seenA.add(aIndex)\n aIndex = (aIndex + occA.size - 1) % occA.size\n }\n\n if (currB.occ == 0) {\n seenB.add(bIndex)\n bIndex = (bIndex + occB.size - 1) % occB.size\n }\n }\n\n var good = true\n for (i in a.indices) good = good && (a[i] != reordering[i])\n if (!good) println(\"No\")\n else {\n println(\"Yes\")\n println(reordering.joinToString(\" \"))\n }\n}\n\ndata class Occurrences(var startIndex: Int, val number: Int, var occ: Int)\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1600053995, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02557.html", "problem_id": "p02557", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02557/input.txt", "sample_output_relpath": "derived/input_output/data/p02557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02557/Kotlin/s397223654.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s397223654", "user_id": "u984465701"}, "prompt_components": {"gold_output": "Yes\n2 2 3 1 1 1\n", "input_to_evaluate": "fun main() {\n val n = readInt()\n val a = readInts()\n val b = readInts()\n\n val occA = mutableListOf()\n val occB = mutableListOf()\n\n fun fillOcc(arr: List, occArr: MutableList, index: Int) {\n if (occArr.isEmpty() || occArr.last().number != arr[index]) occArr.add(Occurrences(index, arr[index], 0))\n occArr.last().occ++\n }\n\n for (i in 0 until n) {\n fillOcc(a, occA, i)\n fillOcc(b, occB, i)\n }\n\n occA.sortBy { it.occ }\n occB.sortBy { it.occ }\n\n var aIndex = occA.size - 1\n var bIndex = if (occB[occB.size - 1].number == occA[aIndex].number) occB.size - 2 else occB.size - 1\n if (bIndex < 0) {\n println(\"No\")\n return\n }\n val seenA = mutableSetOf()\n val seenB = mutableSetOf()\n\n val reordering = IntArray(n)\n while (seenA.size < occA.size && seenB.size < occB.size) {\n val currA = occA[aIndex]\n val currB = occB[bIndex]\n reordering[currA.startIndex] = currB.number\n currA.startIndex++\n currA.occ--\n currB.startIndex++\n currB.occ--\n if (currA.occ == 0) {\n seenA.add(aIndex)\n aIndex = (aIndex + occA.size - 1) % occA.size\n }\n\n if (currB.occ == 0) {\n seenB.add(bIndex)\n bIndex = (bIndex + occB.size - 1) % occB.size\n }\n }\n\n var good = true\n for (i in a.indices) good = good && (a[i] != reordering[i])\n if (!good) println(\"No\")\n else {\n println(\"Yes\")\n println(reordering.joinToString(\" \"))\n }\n}\n\ndata class Occurrences(var startIndex: Int, val number: Int, var occ: Int)\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readStrings() = readLn().trim().split(\" \")\nprivate fun readInt() = readLn().toInt()\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "sample_input": "6\n1 1 1 2 2 3\n1 1 1 2 2 3\n"}, "reference_outputs": ["Yes\n2 2 3 1 1 1\n"], "source_document_id": "p02557", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1876, "cpu_time_ms": 946, "memory_kb": 112744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s465922641", "group_id": "codeNet:p02558", "input_text": "fun main(args : Array) {\n val (n, q) = readLine()!!.split(\" \").map { it.toInt() }\n val uf = UnionFind(n)\n\n repeat(q) {\n val (t, u, v) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (t == 0) {\n uf.merge(u, v)\n } else {\n println(if (uf.isSame(u, v)) 1 else 0)\n }\n }\n}\n\n// Union Find\n// NOTE: initSize is the number of elements\nprivate data class UnionFind(val initSize: Int) {\n private val parents = IntArray(this.initSize) { it }\n private val sizes = LongArray(this.initSize) { 1L }\n\n fun root(idx: Int): Int {\n if (idx == parents[idx]) return idx\n\n val rootP = root(parents[idx])\n parents[idx] = rootP\n return rootP\n }\n\n // NOTE: merge to the larger group\n fun merge(p1: Int, p2: Int) {\n if (this.isSame(p1, p2)) return\n\n val rootP1 = root(p1)\n val rootP2 = root(p2)\n\n if (this.sizes[rootP1] >= this.sizes[rootP2]) {\n this.sizes[rootP1] += this.sizes[rootP2]\n this.parents[rootP2] = this.parents[rootP1]\n } else {\n this.sizes[rootP2] += this.sizes[rootP1]\n this.parents[rootP1] = this.parents[rootP2]\n }\n }\n\n fun isSame(p1: Int, p2: Int): Boolean {\n return this.root(p1) == this.root(p2)\n }\n\n fun size(idx: Int): Long {\n return this.sizes[this.root(idx)]\n }\n}", "language": "Kotlin", "metadata": {"date": 1599527174, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02558.html", "problem_id": "p02558", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02558/input.txt", "sample_output_relpath": "derived/input_output/data/p02558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02558/Kotlin/s465922641.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465922641", "user_id": "u262403099"}, "prompt_components": {"gold_output": "0\n1\n0\n1\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, q) = readLine()!!.split(\" \").map { it.toInt() }\n val uf = UnionFind(n)\n\n repeat(q) {\n val (t, u, v) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (t == 0) {\n uf.merge(u, v)\n } else {\n println(if (uf.isSame(u, v)) 1 else 0)\n }\n }\n}\n\n// Union Find\n// NOTE: initSize is the number of elements\nprivate data class UnionFind(val initSize: Int) {\n private val parents = IntArray(this.initSize) { it }\n private val sizes = LongArray(this.initSize) { 1L }\n\n fun root(idx: Int): Int {\n if (idx == parents[idx]) return idx\n\n val rootP = root(parents[idx])\n parents[idx] = rootP\n return rootP\n }\n\n // NOTE: merge to the larger group\n fun merge(p1: Int, p2: Int) {\n if (this.isSame(p1, p2)) return\n\n val rootP1 = root(p1)\n val rootP2 = root(p2)\n\n if (this.sizes[rootP1] >= this.sizes[rootP2]) {\n this.sizes[rootP1] += this.sizes[rootP2]\n this.parents[rootP2] = this.parents[rootP1]\n } else {\n this.sizes[rootP2] += this.sizes[rootP1]\n this.parents[rootP1] = this.parents[rootP2]\n }\n }\n\n fun isSame(p1: Int, p2: Int): Boolean {\n return this.root(p1) == this.root(p2)\n }\n\n fun size(idx: Int): Long {\n return this.sizes[this.root(idx)]\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n0 u v: Add an edge (u, v).\n\n1 u v: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq Q \\leq 200,000\n\n0 \\leq u_i, v_i \\lt N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n:\nt_Q u_Q v_Q\n\n出力\n\nFor each query of the latter type, print the answer.\n\nSample Input 1\n\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1\n\n0\n1\n0\n1", "sample_input": "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n"}, "reference_outputs": ["0\n1\n0\n1\n"], "source_document_id": "p02558", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n0 u v: Add an edge (u, v).\n\n1 u v: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq Q \\leq 200,000\n\n0 \\leq u_i, v_i \\lt N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n:\nt_Q u_Q v_Q\n\n出力\n\nFor each query of the latter type, print the answer.\n\nSample Input 1\n\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1\n\n0\n1\n0\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1393, "cpu_time_ms": 1065, "memory_kb": 65948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s150602583", "group_id": "codeNet:p02561", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n object {\n val n = readInt()\n val m = readInt()\n\n val S = Array(n) { CharArray(m) { readChar() }.also { readChar() } }\n\n inline fun forEachNeighbor(i: Int, j: Int, yield: (ni: Int, nj: Int, d: Char) -> Unit) {\n if(i > 0) yield(i-1, j, '^') // up / north\n if(i < n -1) yield(i+1, j, 'v') // down / south\n if(j > 0) yield(i, j-1, '<') // left / west\n if(j < m -1) yield(i, j+1, '>') // right / east\n }\n\n val src = n * m\n val snk = src + 1\n val D = Dinic(snk + 1, src, snk)\n\n inline fun v(i: Int, j: Int) = i*m+j\n\n init {\n for(i in 0 until n) for(j in 0 until m) if(S[i][j] == '.') {\n val u = v(i, j)\n if(i xor j and 1 == 0) {\n D.addEdge(src, u, 1)\n forEachNeighbor(i, j) { ni, nj, _ ->\n if(S[ni][nj] == '.') {\n val v = v(ni, nj)\n D.addEdge(u, v, 1)\n }\n }\n } else {\n D.addEdge(u, snk, 1)\n }\n }\n\n val ans = D.maxFlow()\n println(ans)\n\n val F = D.F\n for(i in 0 until n) for(j in 0 until m) if(S[i][j] == '.') {\n val u = v(i, j)\n run {\n forEachNeighbor(i, j) { ni, nj, d ->\n if (F[u][v(ni, nj)] != 0) {\n S[i][j] = d\n return@run\n }\n }\n }\n }\n\n S.forEach(::println)\n }\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ntypealias Cap = Int\nconst val inf = Int.MAX_VALUE\n\nclass Dinic(val n: Int, val s: Int, val t: Int) {\n var solved = false\n val C = Array(n) { IntIntMap() } // capacity\n val F = Array(n) { IntIntMap() } // flow\n\n fun addEdge(u: Int, v: Int, w: Cap) {\n C[u][v] = w\n C[v][u] = 0\n }\n fun addEdge2(u: Int, v: Int, w: Cap) {\n C[u][v] = w\n C[v][u] = w\n }\n\n fun solve() {\n if(solved) return\n solved = true\n\n val adj = Array(n) { C[it].keys() }\n\n while(true) {\n val L = bfs()\n if(L[t] == -1) break\n\n val next = IntArray(n)\n\n val P = intListOf(s)\n\n p@ while (P.isNotEmpty()) {\n if(P.last() == t) {\n var f = Cap.MAX_VALUE\n for (i in 0 until P.lastIndex) {\n val u = P[i]\n val v = P[i + 1]\n next[u]--\n f = min(f, C[u][v] - F[u][v])\n }\n\n for (i in 0 until P.lastIndex) {\n val u = P[i]\n val v = P[i + 1]\n F[u][v] += f\n F[v][u] -= f\n }\n\n P.clear()\n P.add(s)\n }\n\n val u = P.last()\n\n val m = adj[u].size\n while (next[u] < m) {\n val v = adj[u][next[u]++]\n if (F[u][v] < C[u][v] && L[v] == L[u] + 1) {\n P.add(v)\n continue@p\n }\n }\n\n P.pop()\n }\n }\n }\n\n private fun bfs(): IntArray {\n val L = IntArray(n) { -1 }\n val Q = IntDeque()\n Q.add(s)\n L[s] = 0\n\n while(Q.isNotEmpty()) {\n val u = Q.remove()\n for(v in 0 until n) if(L[v] == -1 && F[u][v] < C[u][v]) {\n L[v] = L[u] + 1\n Q.add(v)\n }\n }\n return L\n }\n\n fun maxFlow(): Cap {\n solve()\n return F[s].values().sum()\n }\n}\n\ntypealias IntIntMap = _Ez_Int__Int_HashMap\ninline operator fun IntIntMap.set(key: Int, value: Int) { put(key, value) }\n\nclass _Ez_Int__Int_HashMap(capacity: Int = DEFAULT_CAPACITY) :\n _Ez_Int__Int_Map {\n companion object {\n private const val DEFAULT_CAPACITY = 8\n // There are three invariants for size, removedCount and arraysLength:\n// 1. size + removedCount <= 1/2 arraysLength\n// 2. size > 1/8 arraysLength\n// 3. size >= removedCount\n// arraysLength can be only multiplied by 2 and divided by 2.\n// Also, if it becomes >= 32, it can't become less anymore.\n private const val REBUILD_LENGTH_THRESHOLD = 32\n private const val HASHCODE_INITIAL_VALUE = -0x7ee3623b\n private const val HASHCODE_MULTIPLIER = 0x01000193\n private const val FREE: Byte = 0\n private const val REMOVED: Byte = 1\n private const val FILLED: Byte = 2\n private const /*T2*/ val /*T2*/DEFAULT_NULL_VALUE = 0\n private val hashSeed = random.nextInt()\n }\n\n private lateinit /*T1*/ var keys: IntArray\n private lateinit /*T2*/ var values: IntArray\n private lateinit var status: ByteArray\n override var size = 0\n private set\n private var removedCount = 0\n private var mask = 0\n\n constructor(map: _Ez_Int__Int_Map) : this(map.size) {\n val it = map.iterator()\n while (it.hasNext()) {\n put(it.key, it.value)\n it.next()\n }\n }\n\n constructor(javaMap: Map) : this(javaMap.size) {\n for ((key, value) in javaMap) {\n put(key, value)\n }\n }\n\n private fun getStartPos(h: Int): Int {\n var x = h xor hashSeed\n x = (x xor (x ushr 16)) * 0x7feb352d\n x = (x xor (x ushr 15)) * 0x846ca68b.toInt()\n return (x xor (x ushr 16)) and mask\n }\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun containsKey( /*T1*/\n /*T1*/key: Int\n ): Boolean {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return true\n }\n pos = pos + 1 and mask\n }\n return false\n }\n\n /*T2*/ override fun /*T2*/get( /*T1*/\n /*T1*/key: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return values[pos]\n }\n pos = pos + 1 and mask\n }\n return DEFAULT_NULL_VALUE\n }\n\n /*T2*/ override fun /*T2*/put( /*T1*/\n /*T1*/key: Int, /*T2*/\n /*T2*/value: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] == FILLED) {\n if (keys[pos] == key) {\n val /*T2*/oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n if (status[pos] == FREE) {\n status[pos] = FILLED\n keys[pos] = key\n values[pos] = value\n size++\n if ((size + removedCount) * 2 > keys.size) {\n rebuild(keys.size * 2) // enlarge the table\n }\n return DEFAULT_NULL_VALUE\n }\n val removedPos = pos\n pos = pos + 1 and mask\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val /*T2*/oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n status[removedPos] = FILLED\n keys[removedPos] = key\n values[removedPos] = value\n size++\n removedCount--\n return DEFAULT_NULL_VALUE\n }\n\n /*T2*/ override fun /*T2*/remove( /*T1*/\n /*T1*/key: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val /*T2*/removedValue = values[pos]\n status[pos] = REMOVED\n size--\n removedCount++\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n if (8 * size <= keys.size) {\n rebuild(keys.size / 2) // compress the table\n } else if (size < removedCount) {\n rebuild(keys.size) // just rebuild the table\n }\n }\n return removedValue\n }\n pos = pos + 1 and mask\n }\n return DEFAULT_NULL_VALUE\n }\n\n override fun clear() {\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n initEmptyTable(REBUILD_LENGTH_THRESHOLD)\n } else {\n status.fill(FREE)\n size = 0\n removedCount = 0\n }\n }\n\n /*T1*/ override fun keys(): IntArray { /*T1*/\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < keys.size) {\n if (status[i] == FILLED) {\n result[j++] = keys[i]\n }\n i++\n }\n return result\n }\n\n /*T2*/ override fun values(): IntArray { /*T2*/\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < values.size) {\n if (status[i] == FILLED) {\n result[j++] = values[i]\n }\n i++\n }\n return result\n }\n\n override fun iterator(): _Ez_Int__Int_MapIterator {\n return _Ez_Int__Int_HashMapIterator()\n }\n\n private fun rebuild(newLength: Int) { /*T1*/\n val oldKeys = keys\n /*T2*/\n val oldValues = values\n val oldStatus = status\n initEmptyTable(newLength)\n for (i in oldKeys.indices) {\n if (oldStatus[i] == FILLED) {\n put(oldKeys[i], oldValues[i])\n }\n }\n }\n\n private fun initEmptyTable(length: Int) {\n keys = IntArray(length)\n values = IntArray(length)\n status = ByteArray(length)\n size = 0\n removedCount = 0\n mask = length - 1\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (other == null || javaClass != other.javaClass) return false\n val that = other as _Ez_Int__Int_HashMap\n if (size != that.size) {\n return false\n }\n for (i in keys.indices) {\n if (status[i] == FILLED) { /*T2*/\n val /*T2*/thatValue = that[keys[i]]\n if (thatValue != values[i]) {\n return false\n }\n }\n }\n return true\n }\n\n override fun hashCode(): Int {\n val entryHashes = IntArray(size)\n run {\n var i = 0\n var j = 0\n while (i < status.size) {\n if (status[i] == FILLED) {\n var hash = HASHCODE_INITIAL_VALUE\n hash =\n (hash xor keys[i]) * HASHCODE_MULTIPLIER\n hash =\n (hash xor values[i]) * HASHCODE_MULTIPLIER\n entryHashes[j++] = hash\n }\n i++\n }\n }\n entryHashes.sort()\n var hash = HASHCODE_INITIAL_VALUE\n for (i in 0 until size) {\n hash = (hash xor entryHashes[i]) * HASHCODE_MULTIPLIER\n }\n return hash\n }\n\n override fun toString(): String {\n val sb = StringBuilder()\n sb.append('{')\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n if (sb.length > 1) {\n sb.append(\", \")\n }\n sb.append(keys[i])\n sb.append('=')\n sb.append(values[i])\n }\n }\n sb.append('}')\n return sb.toString()\n }\n\n private inner class _Ez_Int__Int_HashMapIterator : _Ez_Int__Int_MapIterator {\n private var curIndex = 0\n override fun hasNext(): Boolean {\n return curIndex < status.size\n }\n\n /*T1*/ /*T1*/\n override val key: Int\n /*T1*/\n get() {\n if (curIndex == keys.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return keys[curIndex]\n }\n\n /*T2*/ /*T2*/\n override val value: Int\n /*T2*/\n get() {\n if (curIndex == values.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return values[curIndex]\n }\n\n override fun next() {\n if (curIndex == status.size) {\n return\n }\n curIndex++\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n\n init {\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n }\n\n init {\n require(capacity >= 0) { \"Capacity must be non-negative\" }\n // Actually we need 4x more memory\n var length = 4 * max(1, capacity)\n if (length and length - 1 != 0) {\n length = Integer.highestOneBit(length) shl 1\n }\n // Length is a power of 2 now\n initEmptyTable(length)\n }\n}\n\ninterface _Ez_Int__Int_Map {\n // TODO null issues, e.g. when there is no value for a certain key - consider returning special 'null value'\n /**\n * Returns the size of the map, i.e. the number of entries (key-value pairs) in it.\n * @return the size of the map\n */\n val size: Int\n\n /**\n * Checks if the map contains at least one entry (key-value pair).\n * @return `true` if the map doesn't contain any entries, `false` otherwise\n */\n fun isEmpty(): Boolean\n\n /**\n * Checks if the map contains the entry with the specified key.\n * @param key the key to be checked\n * @return `true` if the map contains the entry with the specified key, `false` otherwise\n */\n fun containsKey( /*T1*/\n /*T1*/key: Int\n ): Boolean\n\n /**\n * Returns the value for the specified key. If the map doesn't contain the entry with the specified key, this\n * method can return everything, but sets the special flag, you should check it immediately after using get() this\n * way:\n *
\n     * if (map.returnedNull()) {\n     * // The map doesn't contain the entry with the specified key.\n     * // Take it into account and don't use the value returned by get().\n     * } else {\n     * // The call of get() was successful.\n     * // You can use the value returned by get().\n     * }\n    
*\n * @param key the key of the entry\n * @return the value for the specified key\n * @see .returnedNull\n */\n/*T2*/\n operator fun /*T2*/get( /*T1*/\n /*T1*/key: Int\n ): Int\n\n /**\n * Puts the specified key-value pair into the map. That is, if the map already contains the entry for the specified\n * key, the previous value is overridden by the new one, and if it doesn't, the new entry is created. In the first\n * case, the previous value is returned, and in the second case it can return everything, but the special flag is\n * set. If you are going to use the returned value, you should check it immediately after using put() this way:\n *
\n     * if (map.returnedNull()) {\n     * // The map didn't contain the entry with the specified key. New entry was created.\n     * // Take it into account and don't use the value returned by put().\n     * } else {\n     * // The map contained the entry with the specified key. The value was overridden.\n     * // You can use the previous value returned by put().\n     * }\n    
*\n * @param key the key of the entry\n * @param value the value of the entry\n * @return the previous value for the specified key\n * @see .returnedNull\n */\n/*T2*/\n fun /*T2*/put( /*T1*/\n /*T1*/key: Int, /*T2*/\n /*T2*/value: Int\n ): Int\n\n /**\n * Removes the entry with the specified key from the map. This method returns the value of the removed entry,\n * however, if the map doesn't contain the entry with the specified key, it can return everything, but sets the\n * special flag, you should check it immediately after using remove() this way:\n *
\n     * if (map.returnedNull()) {\n     * // The map doesn't contain the entry with the specified key. Nothing has been removed.\n     * // Take it into account and don't use the value returned by remove().\n     * } else {\n     * // The call of remove() was successful.\n     * // You can use the value returned by remove().\n     * }\n    
*\n * @param key the key of the entry to be removed\n * @return the value of the removed entry\n * @see .returnedNull\n */\n/*T2*/\n fun /*T2*/remove( /*T1*/\n /*T1*/key: Int\n ): Int\n\n /**\n * Removes all entries from the map.\n */\n fun clear()\n\n /**\n * Returns the array which contains all keys in this map. It is not guaranteed that the array will be ordered in\n * any particular order. However, two consecutive calls of `keys()` and [.values] methods return two\n * arrays related to each other such that for every index `i` the entry `(keys[i], values[i])` is\n * contained in the map. This method always allocates new array, so you can modify it and the original map won't\n * be changed, and vice versa.\n * @return the array which contains all keys in this map\n */\n/*T1*/\n fun keys(): IntArray\n\n /**\n * Returns the array which contains all values in this map. It is not guaranteed that the array will be ordered in\n * any particular order. However, two consecutive calls of [.keys] and `values()` methods return two\n * arrays related to each other such that for every index `i` the entry `(keys[i], values[i])` is\n * contained in the map. This method always allocates new array, so you can modify it and the original map won't\n * be changed, and vice versa.\n * @return the array which contains all values in this map\n */\n/*T2*/\n fun values(): IntArray\n\n /**\n * Returns the iterator which can be used to go through the entries of this map. It is not guaranteed that the\n * iterator will return the entries in any particular order.\n * @return the iterator to go through the entries of this map\n */\n operator fun iterator(): _Ez_Int__Int_MapIterator\n\n /**\n * Returns the hashcode of the map. If two maps are equal, their hashcodes are also equal. If the hashcodes of two\n * maps are different, these maps are also different. Please note that different maps can have equal hashcodes,\n * though the probability of this fact is low.\n * @return the hashcode of the map\n */\n override fun hashCode(): Int\n\n /**\n * Returns the human-readable string representation of the map.\n * @return the string representation of the map\n */\n override fun toString(): String\n}\n\ninterface _Ez_Int__Int_MapIterator {\n /**\n * Checks if the iterator has more available entries.\n * @return `true` if the iterator has more entries, `false` otherwise\n */\n operator fun hasNext(): Boolean\n\n /**\n * Returns the key of the entry at which the iterator currently points.\n * @return the key of the entry at which the iterator currently points\n * @throws java.util.NoSuchElementException if the iterator doesn't have more entries\n */\n/*T1*/ /*T1*/\n val key: Int\n\n /**\n * Returns the value of the entry at which the iterator currently points.\n * @return the value of the entry at which the iterator currently points\n * @throws java.util.NoSuchElementException if the iterator doesn't have more entries\n */\n/*T2*/ /*T2*/\n val value: Int\n\n /**\n * Moves the iterator to the next entry in the map. If there are no remaining entries, does nothing.\n */\n operator fun next()\n}\n\ninline fun IntIntMap.forEach(act: (key: Int, value: Int) -> Unit) {\n val ite = iterator()\n while(ite.hasNext()) {\n act(ite.key, ite.value)\n ite.next()\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) { if(s < size) size = s }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n\nclass IntDeque(capacity: Int = 12){\n private var arr = IntArray(capacity)\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n private inline val capacity get() = arr.size\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n private var head = 0\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n val new = IntArray(newCapacity)\n for(i in 0 until size) new[i] = get(i)\n arr = new\n head = 0\n }\n\n private fun incHead() {\n head++\n if(head == capacity) head = 0\n }\n\n private fun decHead() {\n if(head == 0) head = capacity - 1\n else head--\n }\n\n private fun index(i: Int) = (head + i).let { if(it >= capacity) it - capacity else it }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n if(index < size / 2) {\n decHead()\n size++\n for(i in 0 until index) {\n set(i, get(i+1))\n }\n } else {\n size++\n for(i in size - 2 downTo index) {\n set(i+1, get(i))\n }\n }\n set(index, element)\n }\n\n fun addLast(e: Int) {\n if(size == capacity) grow()\n arr[index(size)] = e\n size++\n }\n inline fun add(e: Int) = addLast(e)\n\n val first get() = get(0)\n val last get() = get(lastIndex)\n\n fun removeFirst(): Int {\n val e = get(0)\n incHead()\n size--\n return e\n }\n inline fun remove() = removeFirst()\n fun removeLast(): Int {\n val e = get(lastIndex)\n size--\n return e\n }\n\n fun addFirst(e: Int) {\n if(size == capacity) grow()\n decHead()\n arr[head] = e\n size++\n }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return arr[index(index)]\n }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n if(index < size / 2) {\n for(i in index - 1 downTo 0) {\n set(i+1, get(i))\n }\n incHead()\n } else {\n for(i in index until size - 1) {\n set(i, get(i+1))\n }\n }\n size--\n return e\n }\n\n operator fun set(index: Int, element: Int): Int {\n val old = get(index)\n arr[index(index)] = element\n return old\n }\n\n operator fun iterator() = object: IntIterator() {\n var i = 0\n override fun hasNext(): Boolean = i < size\n override fun nextInt(): Int = get(i++)\n }\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1599820544, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02561.html", "problem_id": "p02561", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02561/input.txt", "sample_output_relpath": "derived/input_output/data/p02561/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02561/Kotlin/s150602583.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s150602583", "user_id": "u596111103"}, "prompt_components": {"gold_output": "3\n#><\nvv#\n^^.\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n object {\n val n = readInt()\n val m = readInt()\n\n val S = Array(n) { CharArray(m) { readChar() }.also { readChar() } }\n\n inline fun forEachNeighbor(i: Int, j: Int, yield: (ni: Int, nj: Int, d: Char) -> Unit) {\n if(i > 0) yield(i-1, j, '^') // up / north\n if(i < n -1) yield(i+1, j, 'v') // down / south\n if(j > 0) yield(i, j-1, '<') // left / west\n if(j < m -1) yield(i, j+1, '>') // right / east\n }\n\n val src = n * m\n val snk = src + 1\n val D = Dinic(snk + 1, src, snk)\n\n inline fun v(i: Int, j: Int) = i*m+j\n\n init {\n for(i in 0 until n) for(j in 0 until m) if(S[i][j] == '.') {\n val u = v(i, j)\n if(i xor j and 1 == 0) {\n D.addEdge(src, u, 1)\n forEachNeighbor(i, j) { ni, nj, _ ->\n if(S[ni][nj] == '.') {\n val v = v(ni, nj)\n D.addEdge(u, v, 1)\n }\n }\n } else {\n D.addEdge(u, snk, 1)\n }\n }\n\n val ans = D.maxFlow()\n println(ans)\n\n val F = D.F\n for(i in 0 until n) for(j in 0 until m) if(S[i][j] == '.') {\n val u = v(i, j)\n run {\n forEachNeighbor(i, j) { ni, nj, d ->\n if (F[u][v(ni, nj)] != 0) {\n S[i][j] = d\n return@run\n }\n }\n }\n }\n\n S.forEach(::println)\n }\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ntypealias Cap = Int\nconst val inf = Int.MAX_VALUE\n\nclass Dinic(val n: Int, val s: Int, val t: Int) {\n var solved = false\n val C = Array(n) { IntIntMap() } // capacity\n val F = Array(n) { IntIntMap() } // flow\n\n fun addEdge(u: Int, v: Int, w: Cap) {\n C[u][v] = w\n C[v][u] = 0\n }\n fun addEdge2(u: Int, v: Int, w: Cap) {\n C[u][v] = w\n C[v][u] = w\n }\n\n fun solve() {\n if(solved) return\n solved = true\n\n val adj = Array(n) { C[it].keys() }\n\n while(true) {\n val L = bfs()\n if(L[t] == -1) break\n\n val next = IntArray(n)\n\n val P = intListOf(s)\n\n p@ while (P.isNotEmpty()) {\n if(P.last() == t) {\n var f = Cap.MAX_VALUE\n for (i in 0 until P.lastIndex) {\n val u = P[i]\n val v = P[i + 1]\n next[u]--\n f = min(f, C[u][v] - F[u][v])\n }\n\n for (i in 0 until P.lastIndex) {\n val u = P[i]\n val v = P[i + 1]\n F[u][v] += f\n F[v][u] -= f\n }\n\n P.clear()\n P.add(s)\n }\n\n val u = P.last()\n\n val m = adj[u].size\n while (next[u] < m) {\n val v = adj[u][next[u]++]\n if (F[u][v] < C[u][v] && L[v] == L[u] + 1) {\n P.add(v)\n continue@p\n }\n }\n\n P.pop()\n }\n }\n }\n\n private fun bfs(): IntArray {\n val L = IntArray(n) { -1 }\n val Q = IntDeque()\n Q.add(s)\n L[s] = 0\n\n while(Q.isNotEmpty()) {\n val u = Q.remove()\n for(v in 0 until n) if(L[v] == -1 && F[u][v] < C[u][v]) {\n L[v] = L[u] + 1\n Q.add(v)\n }\n }\n return L\n }\n\n fun maxFlow(): Cap {\n solve()\n return F[s].values().sum()\n }\n}\n\ntypealias IntIntMap = _Ez_Int__Int_HashMap\ninline operator fun IntIntMap.set(key: Int, value: Int) { put(key, value) }\n\nclass _Ez_Int__Int_HashMap(capacity: Int = DEFAULT_CAPACITY) :\n _Ez_Int__Int_Map {\n companion object {\n private const val DEFAULT_CAPACITY = 8\n // There are three invariants for size, removedCount and arraysLength:\n// 1. size + removedCount <= 1/2 arraysLength\n// 2. size > 1/8 arraysLength\n// 3. size >= removedCount\n// arraysLength can be only multiplied by 2 and divided by 2.\n// Also, if it becomes >= 32, it can't become less anymore.\n private const val REBUILD_LENGTH_THRESHOLD = 32\n private const val HASHCODE_INITIAL_VALUE = -0x7ee3623b\n private const val HASHCODE_MULTIPLIER = 0x01000193\n private const val FREE: Byte = 0\n private const val REMOVED: Byte = 1\n private const val FILLED: Byte = 2\n private const /*T2*/ val /*T2*/DEFAULT_NULL_VALUE = 0\n private val hashSeed = random.nextInt()\n }\n\n private lateinit /*T1*/ var keys: IntArray\n private lateinit /*T2*/ var values: IntArray\n private lateinit var status: ByteArray\n override var size = 0\n private set\n private var removedCount = 0\n private var mask = 0\n\n constructor(map: _Ez_Int__Int_Map) : this(map.size) {\n val it = map.iterator()\n while (it.hasNext()) {\n put(it.key, it.value)\n it.next()\n }\n }\n\n constructor(javaMap: Map) : this(javaMap.size) {\n for ((key, value) in javaMap) {\n put(key, value)\n }\n }\n\n private fun getStartPos(h: Int): Int {\n var x = h xor hashSeed\n x = (x xor (x ushr 16)) * 0x7feb352d\n x = (x xor (x ushr 15)) * 0x846ca68b.toInt()\n return (x xor (x ushr 16)) and mask\n }\n\n override fun isEmpty(): Boolean = size == 0\n\n override fun containsKey( /*T1*/\n /*T1*/key: Int\n ): Boolean {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return true\n }\n pos = pos + 1 and mask\n }\n return false\n }\n\n /*T2*/ override fun /*T2*/get( /*T1*/\n /*T1*/key: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n return values[pos]\n }\n pos = pos + 1 and mask\n }\n return DEFAULT_NULL_VALUE\n }\n\n /*T2*/ override fun /*T2*/put( /*T1*/\n /*T1*/key: Int, /*T2*/\n /*T2*/value: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] == FILLED) {\n if (keys[pos] == key) {\n val /*T2*/oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n if (status[pos] == FREE) {\n status[pos] = FILLED\n keys[pos] = key\n values[pos] = value\n size++\n if ((size + removedCount) * 2 > keys.size) {\n rebuild(keys.size * 2) // enlarge the table\n }\n return DEFAULT_NULL_VALUE\n }\n val removedPos = pos\n pos = pos + 1 and mask\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val /*T2*/oldValue = values[pos]\n values[pos] = value\n return oldValue\n }\n pos = pos + 1 and mask\n }\n status[removedPos] = FILLED\n keys[removedPos] = key\n values[removedPos] = value\n size++\n removedCount--\n return DEFAULT_NULL_VALUE\n }\n\n /*T2*/ override fun /*T2*/remove( /*T1*/\n /*T1*/key: Int\n ): Int {\n var pos = getStartPos(key)\n while (status[pos] != FREE) {\n if (status[pos] == FILLED && keys[pos] == key) {\n val /*T2*/removedValue = values[pos]\n status[pos] = REMOVED\n size--\n removedCount++\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n if (8 * size <= keys.size) {\n rebuild(keys.size / 2) // compress the table\n } else if (size < removedCount) {\n rebuild(keys.size) // just rebuild the table\n }\n }\n return removedValue\n }\n pos = pos + 1 and mask\n }\n return DEFAULT_NULL_VALUE\n }\n\n override fun clear() {\n if (keys.size > REBUILD_LENGTH_THRESHOLD) {\n initEmptyTable(REBUILD_LENGTH_THRESHOLD)\n } else {\n status.fill(FREE)\n size = 0\n removedCount = 0\n }\n }\n\n /*T1*/ override fun keys(): IntArray { /*T1*/\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < keys.size) {\n if (status[i] == FILLED) {\n result[j++] = keys[i]\n }\n i++\n }\n return result\n }\n\n /*T2*/ override fun values(): IntArray { /*T2*/\n val result = IntArray(size)\n var i = 0\n var j = 0\n while (i < values.size) {\n if (status[i] == FILLED) {\n result[j++] = values[i]\n }\n i++\n }\n return result\n }\n\n override fun iterator(): _Ez_Int__Int_MapIterator {\n return _Ez_Int__Int_HashMapIterator()\n }\n\n private fun rebuild(newLength: Int) { /*T1*/\n val oldKeys = keys\n /*T2*/\n val oldValues = values\n val oldStatus = status\n initEmptyTable(newLength)\n for (i in oldKeys.indices) {\n if (oldStatus[i] == FILLED) {\n put(oldKeys[i], oldValues[i])\n }\n }\n }\n\n private fun initEmptyTable(length: Int) {\n keys = IntArray(length)\n values = IntArray(length)\n status = ByteArray(length)\n size = 0\n removedCount = 0\n mask = length - 1\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (other == null || javaClass != other.javaClass) return false\n val that = other as _Ez_Int__Int_HashMap\n if (size != that.size) {\n return false\n }\n for (i in keys.indices) {\n if (status[i] == FILLED) { /*T2*/\n val /*T2*/thatValue = that[keys[i]]\n if (thatValue != values[i]) {\n return false\n }\n }\n }\n return true\n }\n\n override fun hashCode(): Int {\n val entryHashes = IntArray(size)\n run {\n var i = 0\n var j = 0\n while (i < status.size) {\n if (status[i] == FILLED) {\n var hash = HASHCODE_INITIAL_VALUE\n hash =\n (hash xor keys[i]) * HASHCODE_MULTIPLIER\n hash =\n (hash xor values[i]) * HASHCODE_MULTIPLIER\n entryHashes[j++] = hash\n }\n i++\n }\n }\n entryHashes.sort()\n var hash = HASHCODE_INITIAL_VALUE\n for (i in 0 until size) {\n hash = (hash xor entryHashes[i]) * HASHCODE_MULTIPLIER\n }\n return hash\n }\n\n override fun toString(): String {\n val sb = StringBuilder()\n sb.append('{')\n for (i in keys.indices) {\n if (status[i] == FILLED) {\n if (sb.length > 1) {\n sb.append(\", \")\n }\n sb.append(keys[i])\n sb.append('=')\n sb.append(values[i])\n }\n }\n sb.append('}')\n return sb.toString()\n }\n\n private inner class _Ez_Int__Int_HashMapIterator : _Ez_Int__Int_MapIterator {\n private var curIndex = 0\n override fun hasNext(): Boolean {\n return curIndex < status.size\n }\n\n /*T1*/ /*T1*/\n override val key: Int\n /*T1*/\n get() {\n if (curIndex == keys.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return keys[curIndex]\n }\n\n /*T2*/ /*T2*/\n override val value: Int\n /*T2*/\n get() {\n if (curIndex == values.size) {\n throw NoSuchElementException(\"Iterator doesn't have more entries\")\n }\n return values[curIndex]\n }\n\n override fun next() {\n if (curIndex == status.size) {\n return\n }\n curIndex++\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n\n init {\n while (curIndex < status.size && status[curIndex] != FILLED) {\n curIndex++\n }\n }\n }\n\n init {\n require(capacity >= 0) { \"Capacity must be non-negative\" }\n // Actually we need 4x more memory\n var length = 4 * max(1, capacity)\n if (length and length - 1 != 0) {\n length = Integer.highestOneBit(length) shl 1\n }\n // Length is a power of 2 now\n initEmptyTable(length)\n }\n}\n\ninterface _Ez_Int__Int_Map {\n // TODO null issues, e.g. when there is no value for a certain key - consider returning special 'null value'\n /**\n * Returns the size of the map, i.e. the number of entries (key-value pairs) in it.\n * @return the size of the map\n */\n val size: Int\n\n /**\n * Checks if the map contains at least one entry (key-value pair).\n * @return `true` if the map doesn't contain any entries, `false` otherwise\n */\n fun isEmpty(): Boolean\n\n /**\n * Checks if the map contains the entry with the specified key.\n * @param key the key to be checked\n * @return `true` if the map contains the entry with the specified key, `false` otherwise\n */\n fun containsKey( /*T1*/\n /*T1*/key: Int\n ): Boolean\n\n /**\n * Returns the value for the specified key. If the map doesn't contain the entry with the specified key, this\n * method can return everything, but sets the special flag, you should check it immediately after using get() this\n * way:\n *
\n     * if (map.returnedNull()) {\n     * // The map doesn't contain the entry with the specified key.\n     * // Take it into account and don't use the value returned by get().\n     * } else {\n     * // The call of get() was successful.\n     * // You can use the value returned by get().\n     * }\n    
*\n * @param key the key of the entry\n * @return the value for the specified key\n * @see .returnedNull\n */\n/*T2*/\n operator fun /*T2*/get( /*T1*/\n /*T1*/key: Int\n ): Int\n\n /**\n * Puts the specified key-value pair into the map. That is, if the map already contains the entry for the specified\n * key, the previous value is overridden by the new one, and if it doesn't, the new entry is created. In the first\n * case, the previous value is returned, and in the second case it can return everything, but the special flag is\n * set. If you are going to use the returned value, you should check it immediately after using put() this way:\n *
\n     * if (map.returnedNull()) {\n     * // The map didn't contain the entry with the specified key. New entry was created.\n     * // Take it into account and don't use the value returned by put().\n     * } else {\n     * // The map contained the entry with the specified key. The value was overridden.\n     * // You can use the previous value returned by put().\n     * }\n    
*\n * @param key the key of the entry\n * @param value the value of the entry\n * @return the previous value for the specified key\n * @see .returnedNull\n */\n/*T2*/\n fun /*T2*/put( /*T1*/\n /*T1*/key: Int, /*T2*/\n /*T2*/value: Int\n ): Int\n\n /**\n * Removes the entry with the specified key from the map. This method returns the value of the removed entry,\n * however, if the map doesn't contain the entry with the specified key, it can return everything, but sets the\n * special flag, you should check it immediately after using remove() this way:\n *
\n     * if (map.returnedNull()) {\n     * // The map doesn't contain the entry with the specified key. Nothing has been removed.\n     * // Take it into account and don't use the value returned by remove().\n     * } else {\n     * // The call of remove() was successful.\n     * // You can use the value returned by remove().\n     * }\n    
*\n * @param key the key of the entry to be removed\n * @return the value of the removed entry\n * @see .returnedNull\n */\n/*T2*/\n fun /*T2*/remove( /*T1*/\n /*T1*/key: Int\n ): Int\n\n /**\n * Removes all entries from the map.\n */\n fun clear()\n\n /**\n * Returns the array which contains all keys in this map. It is not guaranteed that the array will be ordered in\n * any particular order. However, two consecutive calls of `keys()` and [.values] methods return two\n * arrays related to each other such that for every index `i` the entry `(keys[i], values[i])` is\n * contained in the map. This method always allocates new array, so you can modify it and the original map won't\n * be changed, and vice versa.\n * @return the array which contains all keys in this map\n */\n/*T1*/\n fun keys(): IntArray\n\n /**\n * Returns the array which contains all values in this map. It is not guaranteed that the array will be ordered in\n * any particular order. However, two consecutive calls of [.keys] and `values()` methods return two\n * arrays related to each other such that for every index `i` the entry `(keys[i], values[i])` is\n * contained in the map. This method always allocates new array, so you can modify it and the original map won't\n * be changed, and vice versa.\n * @return the array which contains all values in this map\n */\n/*T2*/\n fun values(): IntArray\n\n /**\n * Returns the iterator which can be used to go through the entries of this map. It is not guaranteed that the\n * iterator will return the entries in any particular order.\n * @return the iterator to go through the entries of this map\n */\n operator fun iterator(): _Ez_Int__Int_MapIterator\n\n /**\n * Returns the hashcode of the map. If two maps are equal, their hashcodes are also equal. If the hashcodes of two\n * maps are different, these maps are also different. Please note that different maps can have equal hashcodes,\n * though the probability of this fact is low.\n * @return the hashcode of the map\n */\n override fun hashCode(): Int\n\n /**\n * Returns the human-readable string representation of the map.\n * @return the string representation of the map\n */\n override fun toString(): String\n}\n\ninterface _Ez_Int__Int_MapIterator {\n /**\n * Checks if the iterator has more available entries.\n * @return `true` if the iterator has more entries, `false` otherwise\n */\n operator fun hasNext(): Boolean\n\n /**\n * Returns the key of the entry at which the iterator currently points.\n * @return the key of the entry at which the iterator currently points\n * @throws java.util.NoSuchElementException if the iterator doesn't have more entries\n */\n/*T1*/ /*T1*/\n val key: Int\n\n /**\n * Returns the value of the entry at which the iterator currently points.\n * @return the value of the entry at which the iterator currently points\n * @throws java.util.NoSuchElementException if the iterator doesn't have more entries\n */\n/*T2*/ /*T2*/\n val value: Int\n\n /**\n * Moves the iterator to the next entry in the map. If there are no remaining entries, does nothing.\n */\n operator fun next()\n}\n\ninline fun IntIntMap.forEach(act: (key: Int, value: Int) -> Unit) {\n val ite = iterator()\n while(ite.hasNext()) {\n act(ite.key, ite.value)\n ite.next()\n }\n}\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun addAll(list: IntList) {\n ensureCapacity(size + list.size)\n list._arr.copyInto(_arr, size, 0, list.size)\n size += list.size\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun popToSize(s: Int) { if(s < size) size = s }\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n\nclass IntDeque(capacity: Int = 12){\n private var arr = IntArray(capacity)\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n private inline val capacity get() = arr.size\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n private var head = 0\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n val new = IntArray(newCapacity)\n for(i in 0 until size) new[i] = get(i)\n arr = new\n head = 0\n }\n\n private fun incHead() {\n head++\n if(head == capacity) head = 0\n }\n\n private fun decHead() {\n if(head == 0) head = capacity - 1\n else head--\n }\n\n private fun index(i: Int) = (head + i).let { if(it >= capacity) it - capacity else it }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n if(index < size / 2) {\n decHead()\n size++\n for(i in 0 until index) {\n set(i, get(i+1))\n }\n } else {\n size++\n for(i in size - 2 downTo index) {\n set(i+1, get(i))\n }\n }\n set(index, element)\n }\n\n fun addLast(e: Int) {\n if(size == capacity) grow()\n arr[index(size)] = e\n size++\n }\n inline fun add(e: Int) = addLast(e)\n\n val first get() = get(0)\n val last get() = get(lastIndex)\n\n fun removeFirst(): Int {\n val e = get(0)\n incHead()\n size--\n return e\n }\n inline fun remove() = removeFirst()\n fun removeLast(): Int {\n val e = get(lastIndex)\n size--\n return e\n }\n\n fun addFirst(e: Int) {\n if(size == capacity) grow()\n decHead()\n arr[head] = e\n size++\n }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return arr[index(index)]\n }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n if(index < size / 2) {\n for(i in index - 1 downTo 0) {\n set(i+1, get(i))\n }\n incHead()\n } else {\n for(i in index until size - 1) {\n set(i, get(i+1))\n }\n }\n size--\n return e\n }\n\n operator fun set(index: Int, element: Int): Int {\n val old = get(index)\n arr[index(index)] = element\n return old\n }\n\n operator fun iterator() = object: IntIterator() {\n var i = 0\n override fun hasNext(): Boolean = i < size\n override fun nextInt(): Int = get(i++)\n }\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nSome of the squares contain an object. All the remaining squares are empty.\nThe state of the grid is represented by strings S_1,S_2,\\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..\n\nConsider placing 1 \\times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.\nTiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.\n\nCalculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\nS_i is a string with length M consists of # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nOn the first line, print the maximum number of tiles that can be placed.\n\nOn the next N lines, print a configulation that achieves the maximum.\nPrecisely, output the strings t_1,t_2,\\cdots,t_N constructed by the following way.\n\nt_i is initialized to S_i.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.\n\nSee samples for further information.\n\nYou may print any configulation that maximizes the number of tiles.\n\nSample Input 1\n\n3 3\n#..\n..#\n...\n\nSample Output 1\n\n3\n#><\nvv#\n^^.\n\nThe following output is also treated as a correct answer.\n\n3\n#><\nv.#\n^><", "sample_input": "3 3\n#..\n..#\n...\n"}, "reference_outputs": ["3\n#><\nvv#\n^^.\n"], "source_document_id": "p02561", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nSome of the squares contain an object. All the remaining squares are empty.\nThe state of the grid is represented by strings S_1,S_2,\\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..\n\nConsider placing 1 \\times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.\nTiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.\n\nCalculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\nS_i is a string with length M consists of # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nOn the first line, print the maximum number of tiles that can be placed.\n\nOn the next N lines, print a configulation that achieves the maximum.\nPrecisely, output the strings t_1,t_2,\\cdots,t_N constructed by the following way.\n\nt_i is initialized to S_i.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.\n\nSee samples for further information.\n\nYou may print any configulation that maximizes the number of tiles.\n\nSample Input 1\n\n3 3\n#..\n..#\n...\n\nSample Output 1\n\n3\n#><\nvv#\n^^.\n\nThe following output is also treated as a correct answer.\n\n3\n#><\nv.#\n^><", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 30941, "cpu_time_ms": 5515, "memory_kb": 56520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s296223180", "group_id": "codeNet:p02570", "input_text": "fun main() {\n val (d, t, s) = readLine()!!.split(\" \").map { it.toInt() }\n println(if(t * s >= d) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1599682225, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Kotlin/s296223180.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s296223180", "user_id": "u685334074"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n val (d, t, s) = readLine()!!.split(\" \").map { it.toInt() }\n println(if(t * s >= d) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 121, "cpu_time_ms": 120, "memory_kb": 36388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s652151922", "group_id": "codeNet:p02577", "input_text": "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 N = ns().map{it-'0'}\n out.println(if (N.sum() % 9 == 0) \"Yes\" else \"No\")\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // なんか本番でエラーでる\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 * 勝手にimport消されるのを防ぎたい\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}\n", "language": "Kotlin", "metadata": {"date": 1598295095, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02577/input.txt", "sample_output_relpath": "derived/input_output/data/p02577/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02577/Kotlin/s652151922.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s652151922", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "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 N = ns().map{it-'0'}\n out.println(if (N.sum() % 9 == 0) \"Yes\" else \"No\")\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n private val isDebug = try {\n // なんか本番でエラーでる\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 * 勝手にimport消されるのを防ぎたい\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}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "sample_input": "123456789\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02577", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2598, "cpu_time_ms": 196, "memory_kb": 40512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s771426446", "group_id": "codeNet:p02577", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\n\nobject Solve {\n\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private val out = PrintWriter(System.out)\n\n fun solve() {\n\n var n = br.readLine()!!\n\n var sum = 0L\n\n for (c in n) {\n sum += (c - '0').toLong()\n }\n\n out.println(if (sum % 9 == 0L) \"Yes\" else \"No\")\n out.flush()\n }\n}\n\nfun main(args: Array) {\n Solve.solve()\n}", "language": "Kotlin", "metadata": {"date": 1598123056, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02577/input.txt", "sample_output_relpath": "derived/input_output/data/p02577/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02577/Kotlin/s771426446.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s771426446", "user_id": "u756514276"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\n\nobject Solve {\n\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private val out = PrintWriter(System.out)\n\n fun solve() {\n\n var n = br.readLine()!!\n\n var sum = 0L\n\n for (c in n) {\n sum += (c - '0').toLong()\n }\n\n out.println(if (sum % 9 == 0L) \"Yes\" else \"No\")\n out.flush()\n }\n}\n\nfun main(args: Array) {\n Solve.solve()\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "sample_input": "123456789\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02577", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 487, "cpu_time_ms": 142, "memory_kb": 37680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s903509610", "group_id": "codeNet:p02578", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toLong() }.toMutableList()\n var sum = 0L\n repeat(n - 1) {\n sum += if(a[it] > a[it + 1]) {\n val tmp = a[it] - a[it + 1]\n a[it + 1] += tmp\n tmp\n } else 0\n }\n print(sum)\n}", "language": "Kotlin", "metadata": {"date": 1599854164, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02578/input.txt", "sample_output_relpath": "derived/input_output/data/p02578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02578/Kotlin/s903509610.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s903509610", "user_id": "u262303334"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toLong() }.toMutableList()\n var sum = 0L\n repeat(n - 1) {\n sum += if(a[it] > a[it + 1]) {\n val tmp = a[it] - a[it + 1]\n a[it + 1] += tmp\n tmp\n } else 0\n }\n print(sum)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 318, "cpu_time_ms": 405, "memory_kb": 71768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s371826406", "group_id": "codeNet:p02578", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val A = readIntArray(n)\n\n var ans = 0L\n var max = 0\n\n for(a in A) {\n max = max(a, max)\n ans += max - a\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "language": "Kotlin", "metadata": {"date": 1598129518, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02578/input.txt", "sample_output_relpath": "derived/input_output/data/p02578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02578/Kotlin/s371826406.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371826406", "user_id": "u596111103"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n// print(\"Case #$case: \")\n\n val n = readInt()\n val A = readIntArray(n)\n\n var ans = 0L\n var max = 0\n\n for(a in A) {\n max = max(a, max)\n ans += max - a\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4558, "cpu_time_ms": 187, "memory_kb": 52596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s536560651", "group_id": "codeNet:p02579", "input_text": "import java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n\n repeat(H){\n map.add(reader.next())\n }\n val neighboursQueue = ArrayDeque>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun isValidPoint(point: Pair, h : Int, w : Int) = point.first >= 0 && point.first < h && point.second >= 0 && point.second < w\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply {\n var checkPoint = Pair(point.first + 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first - 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second + 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second - 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n val sH = point.first - 2\n val sW = point.second - 2\n \n repeat(5){countH->\n repeat(5){ countW->\n val tempH = sH + countH\n val tempW = sW + countW\n\n if((tempH == point.first && (tempW - point.second == 1 || tempW == point.second || tempW -point.second == -1)) ||\n (tempW == point.second &&(tempH - point.first == 1 || tempH == point.first || tempH - point.first == -1)) ||\n !isValidPoint(Pair(tempH, tempW), H, W) ||\n allNeightBours.contains(Pair(tempH, tempW)) ||\n map[tempH][tempW] != '.'){\n\n }\n else {\n add(Pair(tempH, tempW))\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1599123243, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s536560651.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s536560651", "user_id": "u412306454"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n\n repeat(H){\n map.add(reader.next())\n }\n val neighboursQueue = ArrayDeque>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun isValidPoint(point: Pair, h : Int, w : Int) = point.first >= 0 && point.first < h && point.second >= 0 && point.second < w\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply {\n var checkPoint = Pair(point.first + 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first - 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second + 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second - 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n val sH = point.first - 2\n val sW = point.second - 2\n \n repeat(5){countH->\n repeat(5){ countW->\n val tempH = sH + countH\n val tempW = sW + countW\n\n if((tempH == point.first && (tempW - point.second == 1 || tempW == point.second || tempW -point.second == -1)) ||\n (tempW == point.second &&(tempH - point.first == 1 || tempH == point.first || tempH - point.first == -1)) ||\n !isValidPoint(Pair(tempH, tempW), H, W) ||\n allNeightBours.contains(Pair(tempH, tempW)) ||\n map[tempH][tempW] != '.'){\n\n }\n else {\n add(Pair(tempH, tempW))\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3672, "cpu_time_ms": 2208, "memory_kb": 101792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s920142684", "group_id": "codeNet:p02579", "input_text": "\nimport java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n\n repeat(H){\n map.add(reader.next())\n }\n val neighboursQueue = ArrayDeque>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun isValidPoint(point: Pair, h : Int, w : Int) = point.first >= 0 && point.first < h && point.second >= 0 && point.second < w\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply {\n var checkPoint = Pair(point.first + 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first - 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second + 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second - 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n var sH = point.first - 2\n var sW = point.second - 2\n \n repeat(5){\n val tempW = sW + it\n if( isValidPoint(Pair(sH, tempW), H, W) &&\n allNeightBours.contains(Pair(sH, tempW)).not() &&\n map[sH][tempW] == '.' ){\n add(Pair(sH, tempW))\n }\n }\n \n sH += 1\n listOf(sW, sW + 1, sW + 3, sW + 4).forEach{\n if( isValidPoint(Pair(sH, it), H, W) &&\n allNeightBours.contains(Pair(sH, it)).not() &&\n map[sH][it] == '.' ){\n add(Pair(sH, it))\n }\n }\n \n sH += 1\n listOf(sW, sW + 4).forEach{\n if( isValidPoint(Pair(sH, it), H, W) &&\n allNeightBours.contains(Pair(sH, it)).not() &&\n map[sH][it] == '.' ){\n add(Pair(sH, it))\n }\n }\n sH += 1\n listOf(sW, sW + 1, sW + 3, sW + 4).forEach{\n if( isValidPoint(Pair(sH, it), H, W) &&\n allNeightBours.contains(Pair(sH, it)).not() &&\n map[sH][it] == '.' ){\n add(Pair(sH, it))\n }\n }\n sH += 1\n repeat(5){\n val tempW = sW + it\n if( isValidPoint(Pair(sH, tempW), H, W) &&\n allNeightBours.contains(Pair(sH, tempW)).not() &&\n map[sH][tempW] == '.' ){\n add(Pair(sH, tempW))\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1599123087, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s920142684.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s920142684", "user_id": "u412306454"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nimport java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n\n repeat(H){\n map.add(reader.next())\n }\n val neighboursQueue = ArrayDeque>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun isValidPoint(point: Pair, h : Int, w : Int) = point.first >= 0 && point.first < h && point.second >= 0 && point.second < w\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply {\n var checkPoint = Pair(point.first + 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first - 1, point.second)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second + 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n checkPoint = Pair(point.first, point.second - 1)\n if(isValidPoint(checkPoint, H, W) && allNeightBours.contains(checkPoint).not() && map[checkPoint.first][checkPoint.second] == '.' ){\n add(checkPoint)\n }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n var sH = point.first - 2\n var sW = point.second - 2\n \n repeat(5){\n val tempW = sW + it\n if( isValidPoint(Pair(sH, tempW), H, W) &&\n allNeightBours.contains(Pair(sH, tempW)).not() &&\n map[sH][tempW] == '.' ){\n add(Pair(sH, tempW))\n }\n }\n \n sH += 1\n listOf(sW, sW + 1, sW + 3, sW + 4).forEach{\n if( isValidPoint(Pair(sH, it), H, W) &&\n allNeightBours.contains(Pair(sH, it)).not() &&\n map[sH][it] == '.' ){\n add(Pair(sH, it))\n }\n }\n \n sH += 1\n listOf(sW, sW + 4).forEach{\n if( isValidPoint(Pair(sH, it), H, W) &&\n allNeightBours.contains(Pair(sH, it)).not() &&\n map[sH][it] == '.' ){\n add(Pair(sH, it))\n }\n }\n sH += 1\n listOf(sW, sW + 1, sW + 3, sW + 4).forEach{\n if( isValidPoint(Pair(sH, it), H, W) &&\n allNeightBours.contains(Pair(sH, it)).not() &&\n map[sH][it] == '.' ){\n add(Pair(sH, it))\n }\n }\n sH += 1\n repeat(5){\n val tempW = sW + it\n if( isValidPoint(Pair(sH, tempW), H, W) &&\n allNeightBours.contains(Pair(sH, tempW)).not() &&\n map[sH][tempW] == '.' ){\n add(Pair(sH, tempW))\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4276, "cpu_time_ms": 2209, "memory_kb": 104432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s732992173", "group_id": "codeNet:p02579", "input_text": "import java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf>()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n \n repeat(H){row ->\n val rowList = mutableListOf()\n reader.next().forEach{\n rowList.add(it)\n }\n map.add(rowList)\n }\n val neighboursQueue = ArrayDeque>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun isValidPoint(point: Pair, h : Int, w : Int) = point.first >= 0 && point.first < h && point.second >= 0 && point.second < w\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply{\n add(Pair(point.first + 1, point.second))\n add(Pair(point.first - 1, point.second))\n add(Pair(point.first, point.second + 1))\n add(Pair(point.first, point.second - 1))\n filter { isValidPoint(it, H, W) && allNeightBours.contains(it).not() && map[it.first][it.second] == '.' }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n val sH = point.first - 2\n val sW = point.second - 2\n repeat(5){countH->\n repeat(5){ countW->\n val tempH = sH + countH\n val tempW = sW + countW\n\n if((tempH == point.first && (tempW - point.second == 1 || tempW == point.second || tempW -point.second == -1)) ||\n (tempW == point.second &&(tempH - point.first == 1 || tempH == point.first || tempH - point.first == -1)) ||\n map[tempH][tempW] != '.' ||\n !isValidPoint(Pair(tempH, tempW), H, W) ||\n allNeightBours.contains(Pair(tempH, tempW))){\n\n }\n else {\n add(Pair(tempH, tempW))\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1598963182, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s732992173.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s732992173", "user_id": "u412306454"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nval allNeightBours = mutableMapOf,Boolean>()\nval map = mutableListOf>()\nvar H = 0\nvar W = 0\nvar s = Pair(0,0)\nvar t = Pair(0,0)\nfun main(args: Array) {\n val reader = Scanner(System.`in`)\n\n H = reader.nextInt()\n W = reader.nextInt()\n s = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n t = Pair(reader.nextInt() - 1, reader.nextInt() - 1)\n \n repeat(H){row ->\n val rowList = mutableListOf()\n reader.next().forEach{\n rowList.add(it)\n }\n map.add(rowList)\n }\n val neighboursQueue = ArrayDeque>()\n\n neighboursQueue.push(s)\n allNeightBours.put(s, true)\n var swapNum = 0\n var findTarget = false\n\n var checkedNeighbous = mutableListOf>()\n while(neighboursQueue.size > 0 && findTarget.not()){\n val checkPoint = neighboursQueue.pop()\n checkedNeighbous.add(checkPoint)\n val nears = nearNeighbours(checkPoint)\n nears.forEach nearloop@ {\n if(it == t){\n findTarget = true\n return@nearloop\n }\n else {\n neighboursQueue.push(it)\n allNeightBours[it] = true\n\n }\n }\n if(findTarget){\n break\n }\n if(neighboursQueue.size == 0){\n swapNum+= 1\n checkedNeighbous.forEach farloop@{\n farNeighbours(it).forEach {item ->\n if(item == t){\n findTarget = true\n return@farloop\n }\n else {\n neighboursQueue.push(item)\n allNeightBours[item] = true\n }\n }\n }\n checkedNeighbous.clear()\n }\n }\n println(if(findTarget)swapNum else -1)\n}\n\nfun isValidPoint(point: Pair, h : Int, w : Int) = point.first >= 0 && point.first < h && point.second >= 0 && point.second < w\n\nfun nearNeighbours(point : Pair) = mutableListOf>().apply{\n add(Pair(point.first + 1, point.second))\n add(Pair(point.first - 1, point.second))\n add(Pair(point.first, point.second + 1))\n add(Pair(point.first, point.second - 1))\n filter { isValidPoint(it, H, W) && allNeightBours.contains(it).not() && map[it.first][it.second] == '.' }\n}\n\nfun farNeighbours(point : Pair) = mutableListOf>().apply {\n val sH = point.first - 2\n val sW = point.second - 2\n repeat(5){countH->\n repeat(5){ countW->\n val tempH = sH + countH\n val tempW = sW + countW\n\n if((tempH == point.first && (tempW - point.second == 1 || tempW == point.second || tempW -point.second == -1)) ||\n (tempW == point.second &&(tempH - point.first == 1 || tempH == point.first || tempH - point.first == -1)) ||\n map[tempH][tempW] != '.' ||\n !isValidPoint(Pair(tempH, tempW), H, W) ||\n allNeightBours.contains(Pair(tempH, tempW))){\n\n }\n else {\n add(Pair(tempH, tempW))\n }\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3202, "cpu_time_ms": 2221, "memory_kb": 513584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s961035874", "group_id": "codeNet:p02579", "input_text": "\n\nprivate fun getInts(): IntArray {\n return readLine()!!.split(\" \").map {it.toInt()}.toIntArray()\n}\n\nprivate lateinit var originalMap : Array>\nprivate lateinit var islandIdMap : Array>\nprivate lateinit var setOfAdjList : Array>\nprivate var height :Int = 0\nprivate var width : Int = 0\n\nprivate fun isSafe(h:Int,w:Int):Boolean {\n return h >=0 && w >= 0 && h < height && w < width\n}\n\n\nfun main(){\n val hw = getInts()\n height = hw[0]\n width = hw[1]\n val start = getInts()\n val goal = getInts()\n\n // オリジナルを格納\n originalMap = Array(height){arrayOf()}\n for (i in 0 until height) {\n originalMap[i] = readLine()!!.toCharArray().toTypedArray()\n }\n\n // 島マップを作る。\n // 島マップの初期化。島index-1を未訪問とする。\n islandIdMap = Array(height){Array(width){-1}}\n\n // 探索の開始\n var islandCounter = 0\n fun invest(h:Int,w:Int):Boolean {\n if (!isSafe(h,w)){\n // 範囲外\n return false\n }\n if (islandIdMap[h][w] >= 0){\n // 訪問済\n return false\n }\n if (originalMap[h][w] == '#'){\n // 道ではない\n return false\n }\n islandIdMap[h][w] = islandCounter\n invest(h,w+1)\n invest(h,w-1)\n invest(h+1,w)\n invest(h-1,w)\n // 探索が終了したので、この島をカウントする。\n return true\n }\n for (h in 0 until height) {\n for (w in 0 until width) {\n val isNewIsland = invest(h,w)\n if (isNewIsland) {\n islandCounter++\n }\n }\n }\n // islandCounterには島の数が入る。\n\n\n // 島の接続関係を調べる。\n // 島隣接setを初期化\n setOfAdjList = Array(islandCounter) {\n mutableSetOf()\n }\n for (h in 0 until height) {\n for (w in 0 until width) {\n // ワープ可能場所\n val coords = arrayOf(\n Pair(h+2,w+2),\n Pair(h+2,w+1),\n Pair(h+2,w),\n Pair(h+2,w-1),\n Pair(h+2,w-2),\n\n Pair(h+1,w+2),\n Pair(h+1,w+1),\n Pair(h+1,w),\n Pair(h+1,w-1),\n Pair(h+1,w-2),\n\n Pair(h,w+2),\n Pair(h,w+1),\n Pair(h,w-1),\n Pair(h,w-2),\n\n Pair(h-1,w+2),\n Pair(h-1,w+1),\n Pair(h-1,w),\n Pair(h-1,w-1),\n Pair(h-1,w-2),\n\n Pair(h-2,w+2),\n Pair(h-2,w+1),\n Pair(h-2,w),\n Pair(h-2,w-1),\n Pair(h-2,w-2)\n )\n coords.map {\n if (isSafe(it.first,it.second) &&\n originalMap[it.first][it.second] != '#' &&\n originalMap[h][w] != '#'\n ) {\n val islandOfThis = islandIdMap[h][w]\n val another = islandIdMap[it.first][it.second]\n if (islandOfThis != another) {\n setOfAdjList[islandOfThis].add(another)\n }\n }\n }\n }\n }\n\n // 島の幅優先探索\n // 島のワープ回数\n val warpCounter = Array(islandCounter){-1}\n val startIsland = islandIdMap[start[0]-1][start[1]-1]\n val goalIsland = islandIdMap[goal[0]-1][goal[1]-1]\n fun investIsland(count: Int,isLandId:Int) {\n if (warpCounter[isLandId]>=0){\n return\n }\n warpCounter[isLandId] = count\n setOfAdjList[isLandId].map {\n investIsland(count+1,it)\n }\n }\n investIsland(0,startIsland)\n\n// islandIdMap.map{\n// it.map {\n// print(it)\n// print(\"\\t\")\n// }\n// print(\"\\n\")\n// }\n\n print(warpCounter[goalIsland])\n}\n", "language": "Kotlin", "metadata": {"date": 1598129573, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s961035874.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s961035874", "user_id": "u501858653"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\n\nprivate fun getInts(): IntArray {\n return readLine()!!.split(\" \").map {it.toInt()}.toIntArray()\n}\n\nprivate lateinit var originalMap : Array>\nprivate lateinit var islandIdMap : Array>\nprivate lateinit var setOfAdjList : Array>\nprivate var height :Int = 0\nprivate var width : Int = 0\n\nprivate fun isSafe(h:Int,w:Int):Boolean {\n return h >=0 && w >= 0 && h < height && w < width\n}\n\n\nfun main(){\n val hw = getInts()\n height = hw[0]\n width = hw[1]\n val start = getInts()\n val goal = getInts()\n\n // オリジナルを格納\n originalMap = Array(height){arrayOf()}\n for (i in 0 until height) {\n originalMap[i] = readLine()!!.toCharArray().toTypedArray()\n }\n\n // 島マップを作る。\n // 島マップの初期化。島index-1を未訪問とする。\n islandIdMap = Array(height){Array(width){-1}}\n\n // 探索の開始\n var islandCounter = 0\n fun invest(h:Int,w:Int):Boolean {\n if (!isSafe(h,w)){\n // 範囲外\n return false\n }\n if (islandIdMap[h][w] >= 0){\n // 訪問済\n return false\n }\n if (originalMap[h][w] == '#'){\n // 道ではない\n return false\n }\n islandIdMap[h][w] = islandCounter\n invest(h,w+1)\n invest(h,w-1)\n invest(h+1,w)\n invest(h-1,w)\n // 探索が終了したので、この島をカウントする。\n return true\n }\n for (h in 0 until height) {\n for (w in 0 until width) {\n val isNewIsland = invest(h,w)\n if (isNewIsland) {\n islandCounter++\n }\n }\n }\n // islandCounterには島の数が入る。\n\n\n // 島の接続関係を調べる。\n // 島隣接setを初期化\n setOfAdjList = Array(islandCounter) {\n mutableSetOf()\n }\n for (h in 0 until height) {\n for (w in 0 until width) {\n // ワープ可能場所\n val coords = arrayOf(\n Pair(h+2,w+2),\n Pair(h+2,w+1),\n Pair(h+2,w),\n Pair(h+2,w-1),\n Pair(h+2,w-2),\n\n Pair(h+1,w+2),\n Pair(h+1,w+1),\n Pair(h+1,w),\n Pair(h+1,w-1),\n Pair(h+1,w-2),\n\n Pair(h,w+2),\n Pair(h,w+1),\n Pair(h,w-1),\n Pair(h,w-2),\n\n Pair(h-1,w+2),\n Pair(h-1,w+1),\n Pair(h-1,w),\n Pair(h-1,w-1),\n Pair(h-1,w-2),\n\n Pair(h-2,w+2),\n Pair(h-2,w+1),\n Pair(h-2,w),\n Pair(h-2,w-1),\n Pair(h-2,w-2)\n )\n coords.map {\n if (isSafe(it.first,it.second) &&\n originalMap[it.first][it.second] != '#' &&\n originalMap[h][w] != '#'\n ) {\n val islandOfThis = islandIdMap[h][w]\n val another = islandIdMap[it.first][it.second]\n if (islandOfThis != another) {\n setOfAdjList[islandOfThis].add(another)\n }\n }\n }\n }\n }\n\n // 島の幅優先探索\n // 島のワープ回数\n val warpCounter = Array(islandCounter){-1}\n val startIsland = islandIdMap[start[0]-1][start[1]-1]\n val goalIsland = islandIdMap[goal[0]-1][goal[1]-1]\n fun investIsland(count: Int,isLandId:Int) {\n if (warpCounter[isLandId]>=0){\n return\n }\n warpCounter[isLandId] = count\n setOfAdjList[isLandId].map {\n investIsland(count+1,it)\n }\n }\n investIsland(0,startIsland)\n\n// islandIdMap.map{\n// it.map {\n// print(it)\n// print(\"\\t\")\n// }\n// print(\"\\n\")\n// }\n\n print(warpCounter[goalIsland])\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3962, "cpu_time_ms": 1874, "memory_kb": 139184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s943326032", "group_id": "codeNet:p02579", "input_text": "import java.util.ArrayDeque\n\n//\n\nfun main() {\n abc176d()\n}\n\nfun abc176d() {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val (ch, cw) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n val (dh, dw) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n val map = List(h) { CharArray(w) }\n for (i in 0 until h) {\n val s = readLine()!!\n for (j in 0 until w) {\n map[i][j] = s[j]\n }\n }\n val step = List(h) { IntArray(w) { -2 } }\n var wall = ArrayDeque>()\n val next = ArrayDeque>()\n next.add(dh to dw)\n var s = 0\n while (step[ch][cw] == -2) {\n while (next.isNotEmpty()) {\n val (th, tw) = next.poll()\n if (th !in 0 until h) continue\n if (tw !in 0 until w) continue\n if (step[th][tw] > -2) continue\n if (map[th][tw] == '.') {\n step[th][tw] = s\n val startH = (th - 1).coerceAtLeast(0)\n val endH = (th + 1).coerceAtMost(h - 1)\n val startW = (tw - 1).coerceAtLeast(0)\n val endW = (tw + 1).coerceAtMost(w - 1)\n for (i in startH..endH) {\n for (j in startW..endW) {\n if (step[i][j] > -2) continue\n if (map[i][j] == '.') {\n if (th == i || tw == j) next.add(i to j)\n } else {\n wall.add(i to j)\n }\n }\n }\n }\n }\n s++\n while (wall.isNotEmpty()) {\n val (th, tw) = wall.poll()\n if (th !in 0 until h) continue\n if (tw !in 0 until w) continue\n if (step[th][tw] > -2) continue\n if (map[th][tw] == '#') {\n step[th][tw] = -1\n val startH = (th - 1).coerceAtLeast(0)\n val endH = (th + 1).coerceAtMost(h - 1)\n val startW = (tw - 1).coerceAtLeast(0)\n val endW = (tw + 1).coerceAtMost(w - 1)\n for (i in startH .. endH) {\n for (j in startW .. endW) {\n if (map[i][j] == '.' && step[i][j] == -2) next.add(i to j)\n }\n }\n }\n }\n if (next.isEmpty() && wall.isEmpty()) break\n }\n val ans = step[ch][cw]\n println(if (ans < 0) -1 else ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1598127174, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s943326032.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s943326032", "user_id": "u628907033"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.ArrayDeque\n\n//\n\nfun main() {\n abc176d()\n}\n\nfun abc176d() {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val (ch, cw) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n val (dh, dw) = readLine()!!.split(\" \").map { it.toInt() - 1 }\n val map = List(h) { CharArray(w) }\n for (i in 0 until h) {\n val s = readLine()!!\n for (j in 0 until w) {\n map[i][j] = s[j]\n }\n }\n val step = List(h) { IntArray(w) { -2 } }\n var wall = ArrayDeque>()\n val next = ArrayDeque>()\n next.add(dh to dw)\n var s = 0\n while (step[ch][cw] == -2) {\n while (next.isNotEmpty()) {\n val (th, tw) = next.poll()\n if (th !in 0 until h) continue\n if (tw !in 0 until w) continue\n if (step[th][tw] > -2) continue\n if (map[th][tw] == '.') {\n step[th][tw] = s\n val startH = (th - 1).coerceAtLeast(0)\n val endH = (th + 1).coerceAtMost(h - 1)\n val startW = (tw - 1).coerceAtLeast(0)\n val endW = (tw + 1).coerceAtMost(w - 1)\n for (i in startH..endH) {\n for (j in startW..endW) {\n if (step[i][j] > -2) continue\n if (map[i][j] == '.') {\n if (th == i || tw == j) next.add(i to j)\n } else {\n wall.add(i to j)\n }\n }\n }\n }\n }\n s++\n while (wall.isNotEmpty()) {\n val (th, tw) = wall.poll()\n if (th !in 0 until h) continue\n if (tw !in 0 until w) continue\n if (step[th][tw] > -2) continue\n if (map[th][tw] == '#') {\n step[th][tw] = -1\n val startH = (th - 1).coerceAtLeast(0)\n val endH = (th + 1).coerceAtMost(h - 1)\n val startW = (tw - 1).coerceAtLeast(0)\n val endW = (tw + 1).coerceAtMost(w - 1)\n for (i in startH .. endH) {\n for (j in startW .. endW) {\n if (map[i][j] == '.' && step[i][j] == -2) next.add(i to j)\n }\n }\n }\n }\n if (next.isEmpty() && wall.isEmpty()) break\n }\n val ans = step[ch][cw]\n println(if (ans < 0) -1 else ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2446, "cpu_time_ms": 1060, "memory_kb": 73944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s324612653", "group_id": "codeNet:p02579", "input_text": "import java.util.*\n\nfun main(args : Array) {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val c = readLine()!!.split(\" \").map { it.toInt()-1 }\n val d = readLine()!!.split(\" \").map { it.toInt()-1 }\n val ss = Array(h) { readLine()!! }\n\n val seen = Array(h) { IntArray(w) {-1} }\n val bfs = Stack()\n bfs.push(Step(c[0], c[1], 0))\n seen[c[0]][c[1]] = 0\n\n var min = -1\n\n while (bfs.isNotEmpty()) {\n val step = bfs.pop()\n\n if (step.h == d[0] && step.w == d[1]) {\n if (min == -1) {\n min = step.warp\n } else {\n min = Math.min(min, step.warp)\n }\n\n if (min == 0) {\n println(0)\n return\n }\n\n continue\n }\n\n val hs = Math.max(step.h-2, 0)\n val he = Math.min(step.h+2, h-1)\n val ws = Math.max(step.w-2, 0)\n val we = Math.min(step.w+2, w-1)\n\n for (i in hs..he) {\n for (j in ws..we) {\n if (ss[i][j] == '.') {\n if ((i == step.h-1 && j == step.w) || (i == step.h+1 && j == step.w) ||\n (i == step.h && j == step.w-1) || (i == step.h && j == step.w+1)) {\n if (seen[i][j] == -1 || seen[i][j] > step.warp) {\n bfs.push(Step(i, j, step.warp))\n seen[i][j] = step.warp\n }\n } else if (seen[i][j] == -1 || seen[i][j] > step.warp+1) {\n bfs.push(Step(i, j, step.warp+1))\n seen[i][j] = step.warp+1\n }\n }\n }\n }\n }\n\n println(min)\n}\n\ndata class Step(val h: Int, val w: Int, val warp: Int)", "language": "Kotlin", "metadata": {"date": 1598126590, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s324612653.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s324612653", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val c = readLine()!!.split(\" \").map { it.toInt()-1 }\n val d = readLine()!!.split(\" \").map { it.toInt()-1 }\n val ss = Array(h) { readLine()!! }\n\n val seen = Array(h) { IntArray(w) {-1} }\n val bfs = Stack()\n bfs.push(Step(c[0], c[1], 0))\n seen[c[0]][c[1]] = 0\n\n var min = -1\n\n while (bfs.isNotEmpty()) {\n val step = bfs.pop()\n\n if (step.h == d[0] && step.w == d[1]) {\n if (min == -1) {\n min = step.warp\n } else {\n min = Math.min(min, step.warp)\n }\n\n if (min == 0) {\n println(0)\n return\n }\n\n continue\n }\n\n val hs = Math.max(step.h-2, 0)\n val he = Math.min(step.h+2, h-1)\n val ws = Math.max(step.w-2, 0)\n val we = Math.min(step.w+2, w-1)\n\n for (i in hs..he) {\n for (j in ws..we) {\n if (ss[i][j] == '.') {\n if ((i == step.h-1 && j == step.w) || (i == step.h+1 && j == step.w) ||\n (i == step.h && j == step.w-1) || (i == step.h && j == step.w+1)) {\n if (seen[i][j] == -1 || seen[i][j] > step.warp) {\n bfs.push(Step(i, j, step.warp))\n seen[i][j] = step.warp\n }\n } else if (seen[i][j] == -1 || seen[i][j] > step.warp+1) {\n bfs.push(Step(i, j, step.warp+1))\n seen[i][j] = step.warp+1\n }\n }\n }\n }\n }\n\n println(min)\n}\n\ndata class Step(val h: Int, val w: Int, val warp: Int)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1782, "cpu_time_ms": 2208, "memory_kb": 78932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s056456530", "group_id": "codeNet:p02579", "input_text": "import java.util.ArrayDeque\nimport kotlin.Comparator\nimport kotlin.String\n\nfun main(args: Array) {\n val (h, w) = readIntList()\n val (ch, cw) = readIntList().map { it - 1 }\n val (dh, dw) = readIntList().map { it - 1 }\n val s = List(h) { readString() }\n\n val q = ArrayDeque>()\n val ans = List(h) { MutableList(w) { Int.MAX_VALUE } }\n q.addLast(Triple(ch, cw, 0))\n\n val af = listOf(Pair(0, 1), Pair(0, -1), Pair(1, 0), Pair(-1, 0))\n\n while (q.isNotEmpty()) {\n val (x, y, p) = q.removeFirst()\n if (p < ans[x][y]) {\n ans[x][y] = p\n\n af.forEach { (xf, yf) ->\n val tx = x + xf\n val ty = y + yf\n if (tx >= 0 && ty >= 0 && tx < h && ty < w && s[tx][ty] == '.' && ans[x][y] < ans[tx][ty]) {\n q.addLast(Triple(tx, ty, ans[x][y]))\n }\n }\n\n for (xf in -2..2) {\n for (yf in -2..2) {\n if (xf == 0 && yf == 0) continue\n if (xf == x + 1 && yf == y) continue\n if (xf == x - 1 && yf == y) continue\n if (xf == x && yf == y + 1) continue\n if (xf == x && yf == y - 1) continue\n val tx = x + xf\n val ty = y + yf\n if (tx >= 0 && ty >= 0 && tx < h && ty < w && s[tx][ty] == '.' && ans[x][y] + 1 < ans[tx][ty]) {\n q.addLast(Triple(tx, ty, ans[x][y] + 1))\n }\n }\n }\n }\n }\n\n if (ans[dh][dw] == Int.MAX_VALUE) {\n println(-1)\n } else {\n println(ans[dh][dw])\n }\n}\n\n// read\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1598125167, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Kotlin/s056456530.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s056456530", "user_id": "u697467902"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.ArrayDeque\nimport kotlin.Comparator\nimport kotlin.String\n\nfun main(args: Array) {\n val (h, w) = readIntList()\n val (ch, cw) = readIntList().map { it - 1 }\n val (dh, dw) = readIntList().map { it - 1 }\n val s = List(h) { readString() }\n\n val q = ArrayDeque>()\n val ans = List(h) { MutableList(w) { Int.MAX_VALUE } }\n q.addLast(Triple(ch, cw, 0))\n\n val af = listOf(Pair(0, 1), Pair(0, -1), Pair(1, 0), Pair(-1, 0))\n\n while (q.isNotEmpty()) {\n val (x, y, p) = q.removeFirst()\n if (p < ans[x][y]) {\n ans[x][y] = p\n\n af.forEach { (xf, yf) ->\n val tx = x + xf\n val ty = y + yf\n if (tx >= 0 && ty >= 0 && tx < h && ty < w && s[tx][ty] == '.' && ans[x][y] < ans[tx][ty]) {\n q.addLast(Triple(tx, ty, ans[x][y]))\n }\n }\n\n for (xf in -2..2) {\n for (yf in -2..2) {\n if (xf == 0 && yf == 0) continue\n if (xf == x + 1 && yf == y) continue\n if (xf == x - 1 && yf == y) continue\n if (xf == x && yf == y + 1) continue\n if (xf == x && yf == y - 1) continue\n val tx = x + xf\n val ty = y + yf\n if (tx >= 0 && ty >= 0 && tx < h && ty < w && s[tx][ty] == '.' && ans[x][y] + 1 < ans[tx][ty]) {\n q.addLast(Triple(tx, ty, ans[x][y] + 1))\n }\n }\n }\n }\n }\n\n if (ans[dh][dw] == Int.MAX_VALUE) {\n println(-1)\n } else {\n println(ans[dh][dw])\n }\n}\n\n// read\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1984, "cpu_time_ms": 2210, "memory_kb": 121524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s066310468", "group_id": "codeNet:p02582", "input_text": "fun main(args: Array) {\n val s = readString()\n\n val ans = when (s) {\n \"RSS\", \"SRS\", \"SSR\", \"RSR\" -> 1\n \"RRS\", \"SRR\" -> 2\n \"RRR\" -> 3\n else -> 0\n }\n println(ans)\n}\n\n// read\nfun readString() = readLine()!!", "language": "Kotlin", "metadata": {"date": 1597518173, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02582/input.txt", "sample_output_relpath": "derived/input_output/data/p02582/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02582/Kotlin/s066310468.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066310468", "user_id": "u697467902"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readString()\n\n val ans = when (s) {\n \"RSS\", \"SRS\", \"SSR\", \"RSR\" -> 1\n \"RRS\", \"SRR\" -> 2\n \"RRR\" -> 3\n else -> 0\n }\n println(ans)\n}\n\n// read\nfun readString() = readLine()!!", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 251, "cpu_time_ms": 112, "memory_kb": 34496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s273855538", "group_id": "codeNet:p02582", "input_text": "import kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d:String = \" \") = str().split(d)\nfun list(d:String = \" \",f:String.()->T) = read(d).map {f(it)}\nfun list() = list {toInt()}\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n\tabc000X()\n}\n\nfun abc000X() {\n\tstr().split(\"S\").map{it.length}.max().let {println(it)}\n}\n", "language": "Kotlin", "metadata": {"date": 1597518085, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02582/input.txt", "sample_output_relpath": "derived/input_output/data/p02582/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02582/Kotlin/s273855538.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273855538", "user_id": "u059234158"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.*\n\nfun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d:String = \" \") = str().split(d)\nfun list(d:String = \" \",f:String.()->T) = read(d).map {f(it)}\nfun list() = list {toInt()}\n\nfun MutableList.removeLast() = this.removeAt(this.lastIndex)\n\nconst val mod = 1000000007L\n\nfun main() {\n\tabc000X()\n}\n\nfun abc000X() {\n\tstr().split(\"S\").map{it.length}.max().let {println(it)}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 439, "cpu_time_ms": 126, "memory_kb": 36360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s544331267", "group_id": "codeNet:p02583", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var cnt = 0\n for (i in 0 until n) {\n for (j in i + 1 until n) {\n for (k in j + 1 until n) {\n if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {\n if (check(l[i], l[j], l[k])) cnt++\n }\n }\n }\n }\n println(cnt)\n}\n\nfun check(a: Int, b: Int, c: Int): Boolean = when {\n a + b <= c -> {\n false\n }\n a + c <= b -> {\n false\n }\n b + c <= a -> {\n false\n }\n else -> true\n}", "language": "Kotlin", "metadata": {"date": 1597554084, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/Kotlin/s544331267.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s544331267", "user_id": "u366280250"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var cnt = 0\n for (i in 0 until n) {\n for (j in i + 1 until n) {\n for (k in j + 1 until n) {\n if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {\n if (check(l[i], l[j], l[k])) cnt++\n }\n }\n }\n }\n println(cnt)\n}\n\nfun check(a: Int, b: Int, c: Int): Boolean = when {\n a + b <= c -> {\n false\n }\n a + c <= b -> {\n false\n }\n b + c <= a -> {\n false\n }\n else -> true\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 599, "cpu_time_ms": 172, "memory_kb": 38864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s133100879", "group_id": "codeNet:p02583", "input_text": "//\n\nfun main() {\n abc175b()\n}\n\nfun abc175b() {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map { it.toLong() }\n var count = 0L\n for (i in 0 until n - 2) {\n for (j in i + 1 until n - 1) {\n if (l[i] == l[j]) continue\n for (k in j + 1 until n) {\n if (l[k] == l[i] || l[k] == l[j]) continue\n val array = listOf(l[i], l[j], l[k])\n val sorted = array.sortedDescending()\n if (sorted[0] < sorted[2] + sorted[1]) {\n count++\n }\n }\n }\n }\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1597522832, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/Kotlin/s133100879.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133100879", "user_id": "u628907033"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "//\n\nfun main() {\n abc175b()\n}\n\nfun abc175b() {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map { it.toLong() }\n var count = 0L\n for (i in 0 until n - 2) {\n for (j in i + 1 until n - 1) {\n if (l[i] == l[j]) continue\n for (k in j + 1 until n) {\n if (l[k] == l[i] || l[k] == l[j]) continue\n val array = listOf(l[i], l[j], l[k])\n val sorted = array.sortedDescending()\n if (sorted[0] < sorted[2] + sorted[1]) {\n count++\n }\n }\n }\n }\n println(count)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 626, "cpu_time_ms": 278, "memory_kb": 55616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s501617117", "group_id": "codeNet:p02583", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val lList = readListOfLong()\n var cnt = 0L\n for(ai in 0 until n-2) {\n val a = lList[ai]\n for(bi in ai + 1 until n-1) {\n val b = lList[bi]\n for(ci in bi + 1 until n) {\n val c = lList[ci]\n if(a != b && b != c && a != c && \n a + b > c && b + c > a && c + a > b) {\n cnt++\n }\n }\n }\n }\n\n println(cnt)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[num] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1597518854, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/Kotlin/s501617117.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s501617117", "user_id": "u026686258"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val lList = readListOfLong()\n var cnt = 0L\n for(ai in 0 until n-2) {\n val a = lList[ai]\n for(bi in ai + 1 until n-1) {\n val b = lList[bi]\n for(ci in bi + 1 until n) {\n val c = lList[ci]\n if(a != b && b != c && a != c && \n a + b > c && b + c > a && c + a > b) {\n cnt++\n }\n }\n }\n }\n\n println(cnt)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[num] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6242, "cpu_time_ms": 167, "memory_kb": 38628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s914609142", "group_id": "codeNet:p02583", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val l = (0 until n).map { sc.next().toLong() }\n println(problem175b(n, l))\n}\n\nfun problem175b(n: Int, l: List): Long {\n var count = 0L\n for (i in 0 until n) {\n val a = l[i]\n for (j in i + 1 until n) {\n val b = l[j]\n if (a == b) continue\n for (k in j + 1 until n) {\n val c = l[k]\n if (b == c || a == c) continue\n if (a + b > c && b + c > a && c + a > b) count++\n }\n }\n }\n return count\n}", "language": "Kotlin", "metadata": {"date": 1597518751, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/Kotlin/s914609142.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s914609142", "user_id": "u073232808"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val l = (0 until n).map { sc.next().toLong() }\n println(problem175b(n, l))\n}\n\nfun problem175b(n: Int, l: List): Long {\n var count = 0L\n for (i in 0 until n) {\n val a = l[i]\n for (j in i + 1 until n) {\n val b = l[j]\n if (a == b) continue\n for (k in j + 1 until n) {\n val c = l[k]\n if (b == c || a == c) continue\n if (a + b > c && b + c > a && c + a > b) count++\n }\n }\n }\n return count\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 631, "cpu_time_ms": 186, "memory_kb": 38792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s539585611", "group_id": "codeNet:p02584", "input_text": "fun main() {\n val (x, k, d) = readLine()!!.split(\" \").map(String::toLong)\n \n val x_abs = Math.abs(x)\n \n if(x_abs <= d) {\n if(k%2==0L) println(x_abs) else println(d-x_abs)\n return\n }\n \n if(d*k <= x_abs) {\n println(x_abs - d*k)\n return\n }\n \n if((k-x_abs/d) % 2 == 0L) println(x_abs%d) else println(d - x_abs%d)\n}", "language": "Kotlin", "metadata": {"date": 1597583951, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/Kotlin/s539585611.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s539585611", "user_id": "u966836999"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val (x, k, d) = readLine()!!.split(\" \").map(String::toLong)\n \n val x_abs = Math.abs(x)\n \n if(x_abs <= d) {\n if(k%2==0L) println(x_abs) else println(d-x_abs)\n return\n }\n \n if(d*k <= x_abs) {\n println(x_abs - d*k)\n return\n }\n \n if((k-x_abs/d) % 2 == 0L) println(x_abs%d) else println(d - x_abs%d)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 333, "cpu_time_ms": 111, "memory_kb": 36472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s839339516", "group_id": "codeNet:p02584", "input_text": "import java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.abs\n\nfun main() {\n\n fun PrintWriter.solve() {\n var (x,k,d) = List(3){nextLong()}\n if(x >= 0){\n if (x >= k * d) {\n println(\"${x - k * d}\")\n } else {\n val nk = x / d\n k -= nk\n x = x - nk * d\n if (k % 2 == 0L) {\n println(\"${x}\")\n } else {\n println(\"${-(x - d)}\")\n }\n }\n }\n else{\n if (x + k*d <= 0){\n println(\"${abs(x+k*d)}\")\n }\n else{\n val nk = (-x)/d\n k -= nk\n if (k%2 == 0L){\n println(\"${abs(x)}\")\n }\n else{\n println(\"${abs(x+d)}\")\n }\n }\n }\n\n\n }\n\n writer.solve()\n writer.flush()\n\n\n}\n\n\nprivate val reader = System.`in`.bufferedReader()\nprivate val writer = PrintWriter(System.out, false)\n\nprivate var tokenizer: StringTokenizer = StringTokenizer(\"\")\n\nprivate fun next(): String {\n while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())\n return tokenizer.nextToken()\n}\n\nprivate fun nextInt() = next().toInt()\nprivate fun nextLong() = next().toLong()\nprivate fun nextDouble() = next().toDouble()\nprivate fun nextLine() = reader.readLine()\n\n", "language": "Kotlin", "metadata": {"date": 1597583653, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/Kotlin/s839339516.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s839339516", "user_id": "u424241608"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.StringTokenizer\nimport kotlin.math.abs\n\nfun main() {\n\n fun PrintWriter.solve() {\n var (x,k,d) = List(3){nextLong()}\n if(x >= 0){\n if (x >= k * d) {\n println(\"${x - k * d}\")\n } else {\n val nk = x / d\n k -= nk\n x = x - nk * d\n if (k % 2 == 0L) {\n println(\"${x}\")\n } else {\n println(\"${-(x - d)}\")\n }\n }\n }\n else{\n if (x + k*d <= 0){\n println(\"${abs(x+k*d)}\")\n }\n else{\n val nk = (-x)/d\n k -= nk\n if (k%2 == 0L){\n println(\"${abs(x)}\")\n }\n else{\n println(\"${abs(x+d)}\")\n }\n }\n }\n\n\n }\n\n writer.solve()\n writer.flush()\n\n\n}\n\n\nprivate val reader = System.`in`.bufferedReader()\nprivate val writer = PrintWriter(System.out, false)\n\nprivate var tokenizer: StringTokenizer = StringTokenizer(\"\")\n\nprivate fun next(): String {\n while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())\n return tokenizer.nextToken()\n}\n\nprivate fun nextInt() = next().toInt()\nprivate fun nextLong() = next().toLong()\nprivate fun nextDouble() = next().toDouble()\nprivate fun nextLine() = reader.readLine()\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1463, "cpu_time_ms": 94, "memory_kb": 34516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s114728966", "group_id": "codeNet:p02584", "input_text": "import kotlin.math.abs\nimport kotlin.math.ceil\n\nfun main() {\n val (_x, k, d) = readLine()!!.split(\" \").map { it.toLong() }\n val x = abs(_x)\n\n val res = when {\n k < ceil(x.toDouble() / d) -> {\n x - k * d\n }\n (k - x / d) % 2 == 0L -> {\n x % d\n }\n else -> {\n abs(x % d - d)\n }\n }\n\n println(res)\n}\n", "language": "Kotlin", "metadata": {"date": 1597534639, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/Kotlin/s114728966.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114728966", "user_id": "u657541767"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.ceil\n\nfun main() {\n val (_x, k, d) = readLine()!!.split(\" \").map { it.toLong() }\n val x = abs(_x)\n\n val res = when {\n k < ceil(x.toDouble() / d) -> {\n x - k * d\n }\n (k - x / d) % 2 == 0L -> {\n x % d\n }\n else -> {\n abs(x % d - d)\n }\n }\n\n println(res)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 384, "cpu_time_ms": 129, "memory_kb": 36508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s198521172", "group_id": "codeNet:p02584", "input_text": "import kotlin.math.abs\nimport kotlin.math.min\n\nfun main(){\n val (x, k, d) = readLine()!!.split(\" \").map { it.toLong() }\n if (x >= 0){\n val saitan = x / d\n if (k <= saitan){\n if (k <= 100000000){\n var ans = x\n for (i in 0 until k){\n ans -= d\n }\n println(ans)\n } else {\n println(abs(x - k * d))\n }\n } else {\n if ((k - saitan) % 2 == 0L){\n println(abs(x % d))\n } else {\n println(abs(x % d - d))\n }\n }\n } else {\n val useX = x * -1\n val saitan = useX / d\n if (k <= saitan){\n if (k <= 100000000){\n var ans = x\n for (i in 0 until k){\n ans += d\n }\n println(ans)\n } else {\n println(abs((k * d - x)))\n }\n } else {\n if ((k - saitan) % 2 == 0L){\n println(abs(x % d))\n } else {\n println(abs(x % d + d))\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1597523336, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/Kotlin/s198521172.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s198521172", "user_id": "u385678999"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.min\n\nfun main(){\n val (x, k, d) = readLine()!!.split(\" \").map { it.toLong() }\n if (x >= 0){\n val saitan = x / d\n if (k <= saitan){\n if (k <= 100000000){\n var ans = x\n for (i in 0 until k){\n ans -= d\n }\n println(ans)\n } else {\n println(abs(x - k * d))\n }\n } else {\n if ((k - saitan) % 2 == 0L){\n println(abs(x % d))\n } else {\n println(abs(x % d - d))\n }\n }\n } else {\n val useX = x * -1\n val saitan = useX / d\n if (k <= saitan){\n if (k <= 100000000){\n var ans = x\n for (i in 0 until k){\n ans += d\n }\n println(ans)\n } else {\n println(abs((k * d - x)))\n }\n } else {\n if ((k - saitan) % 2 == 0L){\n println(abs(x % d))\n } else {\n println(abs(x % d + d))\n }\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1155, "cpu_time_ms": 118, "memory_kb": 36436}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s264541330", "group_id": "codeNet:p02585", "input_text": "import kotlin.math.max\nimport kotlin.math.min\n\nfun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun longList() = readLine()?.split(\" \")?.map(String::toLong) ?: TODO()\nfun main() {\n val (n, k) = longList()\n val p = intList()\n val c = longList()\n val maps = mutableListOf>()\n var m = Long.MIN_VALUE\n repeat(n.toInt()) { i ->\n var index = i\n val route = maps.find { it.containsKey(p[index]) } ?: run {\n val map = hashMapOf()\n while (true) {\n val next = p[index]\n if (map.containsKey(next)) {\n map[-1] = map.values.sum()\n maps.add(map)\n break\n } else {\n index = next - 1\n map[next] = c[index]\n }\n }\n map\n }\n val routeSize = route.keys.size - 1\n val loop = k / routeSize\n val seed = (route[-1] ?: 0) * loop\n if (seed > 0) {\n val remain = (k % routeSize).toInt()\n var score = 0L\n index = i\n repeat(remain) {\n val next = p[index]\n index = next - 1\n score += c[index]\n m = max(seed + score, m)\n }\n m = max(seed + score, m)\n } else {\n var score = 0L\n index = i\n repeat(min(k.toInt(), routeSize)) {\n val next = p[index]\n index = next - 1\n score += c[index]\n m = max(score, m)\n }\n m = max(score, m)\n }\n }\n println(m.toString())\n}\n", "language": "Kotlin", "metadata": {"date": 1597804832, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02585/input.txt", "sample_output_relpath": "derived/input_output/data/p02585/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02585/Kotlin/s264541330.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s264541330", "user_id": "u979429407"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import kotlin.math.max\nimport kotlin.math.min\n\nfun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun longList() = readLine()?.split(\" \")?.map(String::toLong) ?: TODO()\nfun main() {\n val (n, k) = longList()\n val p = intList()\n val c = longList()\n val maps = mutableListOf>()\n var m = Long.MIN_VALUE\n repeat(n.toInt()) { i ->\n var index = i\n val route = maps.find { it.containsKey(p[index]) } ?: run {\n val map = hashMapOf()\n while (true) {\n val next = p[index]\n if (map.containsKey(next)) {\n map[-1] = map.values.sum()\n maps.add(map)\n break\n } else {\n index = next - 1\n map[next] = c[index]\n }\n }\n map\n }\n val routeSize = route.keys.size - 1\n val loop = k / routeSize\n val seed = (route[-1] ?: 0) * loop\n if (seed > 0) {\n val remain = (k % routeSize).toInt()\n var score = 0L\n index = i\n repeat(remain) {\n val next = p[index]\n index = next - 1\n score += c[index]\n m = max(seed + score, m)\n }\n m = max(seed + score, m)\n } else {\n var score = 0L\n index = i\n repeat(min(k.toInt(), routeSize)) {\n val next = p[index]\n index = next - 1\n score += c[index]\n m = max(score, m)\n }\n m = max(score, m)\n }\n }\n println(m.toString())\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "sample_input": "5 2\n2 4 5 1 3\n3 4 -10 -8 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02585", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1692, "cpu_time_ms": 538, "memory_kb": 50436}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s289873046", "group_id": "codeNet:p02585", "input_text": "fun main() {\n val (N, K) = readInts()\n val P = readInts().map { it - 1 }\n val C = readInts()\n\n fun f(begin: Int): Long {\n val visited = Array(N) { false }\n val scores = Array(N) { Long.MIN_VALUE } // i ステップの時の score\n var p = begin\n visited[begin] = true\n var score = 0L\n var stepNum = 0\n for (i in 0 until K) {\n stepNum++\n visited[p] = true\n score += C[p]\n scores[i] = score\n p = P[p]\n if (visited[p]) break\n }\n var max = Long.MIN_VALUE\n val lastScore = scores[stepNum - 1]\n if (K <= stepNum || lastScore <= 0L) {\n max = scores.max()!!\n } else {\n val loopNum = K / stepNum\n val bonus = lastScore * loopNum\n val k = K - stepNum * loopNum\n max = bonus + ((0 until k).map { scores[it] }.max() ?: 0L)\n }\n return max\n }\n\n val results = (0 until N).map { f(it) }\n println(results.max())\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1597545330, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02585/input.txt", "sample_output_relpath": "derived/input_output/data/p02585/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02585/Kotlin/s289873046.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s289873046", "user_id": "u979004569"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main() {\n val (N, K) = readInts()\n val P = readInts().map { it - 1 }\n val C = readInts()\n\n fun f(begin: Int): Long {\n val visited = Array(N) { false }\n val scores = Array(N) { Long.MIN_VALUE } // i ステップの時の score\n var p = begin\n visited[begin] = true\n var score = 0L\n var stepNum = 0\n for (i in 0 until K) {\n stepNum++\n visited[p] = true\n score += C[p]\n scores[i] = score\n p = P[p]\n if (visited[p]) break\n }\n var max = Long.MIN_VALUE\n val lastScore = scores[stepNum - 1]\n if (K <= stepNum || lastScore <= 0L) {\n max = scores.max()!!\n } else {\n val loopNum = K / stepNum\n val bonus = lastScore * loopNum\n val k = K - stepNum * loopNum\n max = bonus + ((0 until k).map { scores[it] }.max() ?: 0L)\n }\n return max\n }\n\n val results = (0 until N).map { f(it) }\n println(results.max())\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readLong() = readString().toLong()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "sample_input": "5 2\n2 4 5 1 3\n3 4 -10 -8 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02585", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1156, "cpu_time_ms": 1440, "memory_kb": 61936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s513139763", "group_id": "codeNet:p02586", "input_text": "import java.io.BufferedReader\nimport java.util.*\nimport kotlin.math.max\n\nfun main() = abc175e()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc175e() = SimpleFastIOWithToken_abc175e().exec {\n val (rows, cols, k) = List(3) { readInt() }\n val items = List(k) { List(3) { readInt() } }\n\n val grid = Array(rows) { LongArray(cols) }\n items.forEach { (r, c, v) -> grid[r - 1][c - 1] = v.toLong() }\n val rowMaxes = LongArray(cols)\n\n for (y in 0 until rows) {\n val rowDp = Array(4) { LongArray(cols) }\n rowDp[0] = rowMaxes\n\n for (x in 0 until cols) {\n for (take in 2 downTo 0) {\n rowDp[take + 1][x] = max(rowDp[take + 1][x], rowDp[take][x] + grid[y][x])\n }\n\n if (x + 1 < cols) for (take in 0..3) {\n rowDp[take][x + 1] = max(rowDp[take][x + 1], rowDp[take][x])\n }\n }\n\n for (x in 0 until cols) rowMaxes.changeMax(x, rowDp.map { it[x] }.max()!!)\n }\n\n val answer = rowMaxes.last()\n\n println(answer)\n}\n\nprivate fun LongArray.changeMax(i: Int, v: Long) = run { this[i] = max(this[i], v) }\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"HasPlatformType\", \"MemberVisibilityCanBePrivate\", \"ClassName\")\nprivate class SimpleFastIOWithToken_abc175e(private val separator: String = System.lineSeparator()) {\n private val br: BufferedReader = System.`in`.bufferedReader()\n private var st: StringTokenizer = StringTokenizer(\"\")\n private val sb: StringBuilder = StringBuilder()\n private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }\n\n fun readString(): String = run { prepareNext() }.run { st.nextToken() }\n fun readInt(): Int = Integer.valueOf(readString())\n fun readLong(): Long = java.lang.Long.valueOf(readString())\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n\n fun exec(action: SimpleFastIOWithToken_abc175e.() -> Unit) {\n var t: Throwable? = null\n Thread(null, { action() }, \"solve\", 128 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }\n .apply { start() }.join()\n t?.let { throw it }\n kotlin.io.print(sb)\n }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "language": "Kotlin", "metadata": {"date": 1597556167, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Kotlin/s513139763.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s513139763", "user_id": "u139478771"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.util.*\nimport kotlin.math.max\n\nfun main() = abc175e()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc175e() = SimpleFastIOWithToken_abc175e().exec {\n val (rows, cols, k) = List(3) { readInt() }\n val items = List(k) { List(3) { readInt() } }\n\n val grid = Array(rows) { LongArray(cols) }\n items.forEach { (r, c, v) -> grid[r - 1][c - 1] = v.toLong() }\n val rowMaxes = LongArray(cols)\n\n for (y in 0 until rows) {\n val rowDp = Array(4) { LongArray(cols) }\n rowDp[0] = rowMaxes\n\n for (x in 0 until cols) {\n for (take in 2 downTo 0) {\n rowDp[take + 1][x] = max(rowDp[take + 1][x], rowDp[take][x] + grid[y][x])\n }\n\n if (x + 1 < cols) for (take in 0..3) {\n rowDp[take][x + 1] = max(rowDp[take][x + 1], rowDp[take][x])\n }\n }\n\n for (x in 0 until cols) rowMaxes.changeMax(x, rowDp.map { it[x] }.max()!!)\n }\n\n val answer = rowMaxes.last()\n\n println(answer)\n}\n\nprivate fun LongArray.changeMax(i: Int, v: Long) = run { this[i] = max(this[i], v) }\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"HasPlatformType\", \"MemberVisibilityCanBePrivate\", \"ClassName\")\nprivate class SimpleFastIOWithToken_abc175e(private val separator: String = System.lineSeparator()) {\n private val br: BufferedReader = System.`in`.bufferedReader()\n private var st: StringTokenizer = StringTokenizer(\"\")\n private val sb: StringBuilder = StringBuilder()\n private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }\n\n fun readString(): String = run { prepareNext() }.run { st.nextToken() }\n fun readInt(): Int = Integer.valueOf(readString())\n fun readLong(): Long = java.lang.Long.valueOf(readString())\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n\n fun exec(action: SimpleFastIOWithToken_abc175e.() -> Unit) {\n var t: Throwable? = null\n Thread(null, { action() }, \"solve\", 128 * 1024 * 1024)\n .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }\n .apply { start() }.join()\n t?.let { throw it }\n kotlin.io.print(sb)\n }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2438, "cpu_time_ms": 1376, "memory_kb": 182616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494512969", "group_id": "codeNet:p02586", "input_text": "fun main(args: Array) {\n val (r, c, k) = readLine()!!.toString().split(' ').map { it.toInt() }\n val matrix = Array(r) { LongArray(c) }\n for (i in 0 until k) {\n val (r, c, v) = readLine()!!.toString().split(' ').map { it.toInt() }\n matrix[r - 1][c - 1] = v.toLong()\n }\n val seen = HashMap, Long>()\n\n fun dfs(x: Int, y: Int, cur: Int): Long {\n val key = Triple(x, y, cur)\n if (key in seen) return seen[key]!!\n if (x < 0 || y < 0) return 0\n if (cur >= 3) return dfs(x - 1, y, 0).also { seen[key] = it }\n if (matrix[x][y] == 0L) return maxOf(dfs(x - 1, y, cur), dfs(x, y - 1, 0)).also {\n seen[key] = it\n }\n return maxOf(maxOf(dfs(x, y - 1, cur), dfs(x, y - 1, cur + 1) + matrix[x][y]), dfs(x - 1, y, 0) + matrix[x][y]).also {\n seen[key] = it\n }\n }\n\n println(dfs(r - 1, c - 1, 0))\n}", "language": "Kotlin", "metadata": {"date": 1597544268, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Kotlin/s494512969.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s494512969", "user_id": "u231726477"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val (r, c, k) = readLine()!!.toString().split(' ').map { it.toInt() }\n val matrix = Array(r) { LongArray(c) }\n for (i in 0 until k) {\n val (r, c, v) = readLine()!!.toString().split(' ').map { it.toInt() }\n matrix[r - 1][c - 1] = v.toLong()\n }\n val seen = HashMap, Long>()\n\n fun dfs(x: Int, y: Int, cur: Int): Long {\n val key = Triple(x, y, cur)\n if (key in seen) return seen[key]!!\n if (x < 0 || y < 0) return 0\n if (cur >= 3) return dfs(x - 1, y, 0).also { seen[key] = it }\n if (matrix[x][y] == 0L) return maxOf(dfs(x - 1, y, cur), dfs(x, y - 1, 0)).also {\n seen[key] = it\n }\n return maxOf(maxOf(dfs(x, y - 1, cur), dfs(x, y - 1, cur + 1) + matrix[x][y]), dfs(x - 1, y, 0) + matrix[x][y]).also {\n seen[key] = it\n }\n }\n\n println(dfs(r - 1, c - 1, 0))\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 934, "cpu_time_ms": 787, "memory_kb": 147284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s015535334", "group_id": "codeNet:p02594", "input_text": "import java.io.IOException\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\nobject AMain{\n fun solve(){\n val x = nextInt()\n if(x >= 30){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n }\n\n // Scanner based on uwi-san's Java FastScanner\n val stream = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n\n fun hasNextByte(): Boolean{\n if(ptr < buflen){\n return true\n }else{\n ptr = 0\n try{\n buflen = stream.read(buffer)\n }catch (e: IOException){\n e.printStackTrace()\n }\n if(buflen <= 0){\n return false\n }\n }\n return true\n }\n\n fun readByte() =\n if(hasNextByte()) buffer[ptr++]\n else -1\n\n fun isPrintableChar(c: Byte) = c in 33..126\n\n fun hasNext(): Boolean{\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n fun next(): String{\n if(!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while(isPrintableChar(b)){\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long{\n if(!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if(b == '-'.toByte()){\n minus = true\n b = readByte()\n }\n if(b !in '0'.toByte()..'9'.toByte())\n throw NumberFormatException()\n while(true){\n if(b in '0'.toByte()..'9'.toByte()){\n n *= 10\n n += b - '0'.toByte()\n }else if(!isPrintableChar(b)){\n return if(minus) -n else n\n }else{\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int{\n val n1 = nextLong()\n if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)\n throw NumberFormatException()\n return n1.toInt()\n }\n\n fun NextDouble() = next().toDouble()\n}\n\nfun main(){\n AMain.solve()\n}\n\n", "language": "Kotlin", "metadata": {"date": 1597001388, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/Kotlin/s015535334.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s015535334", "user_id": "u097204018"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "import java.io.IOException\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\nobject AMain{\n fun solve(){\n val x = nextInt()\n if(x >= 30){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n }\n\n // Scanner based on uwi-san's Java FastScanner\n val stream = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n\n fun hasNextByte(): Boolean{\n if(ptr < buflen){\n return true\n }else{\n ptr = 0\n try{\n buflen = stream.read(buffer)\n }catch (e: IOException){\n e.printStackTrace()\n }\n if(buflen <= 0){\n return false\n }\n }\n return true\n }\n\n fun readByte() =\n if(hasNextByte()) buffer[ptr++]\n else -1\n\n fun isPrintableChar(c: Byte) = c in 33..126\n\n fun hasNext(): Boolean{\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n fun next(): String{\n if(!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while(isPrintableChar(b)){\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextLong(): Long{\n if(!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if(b == '-'.toByte()){\n minus = true\n b = readByte()\n }\n if(b !in '0'.toByte()..'9'.toByte())\n throw NumberFormatException()\n while(true){\n if(b in '0'.toByte()..'9'.toByte()){\n n *= 10\n n += b - '0'.toByte()\n }else if(!isPrintableChar(b)){\n return if(minus) -n else n\n }else{\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int{\n val n1 = nextLong()\n if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)\n throw NumberFormatException()\n return n1.toInt()\n }\n\n fun NextDouble() = next().toDouble()\n}\n\nfun main(){\n AMain.solve()\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2257, "cpu_time_ms": 94, "memory_kb": 33796}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s220004782", "group_id": "codeNet:p02594", "input_text": "fun main() {\n val x = readLine()!!.toInt()\n\n val answer = if (x >= 30) {\n \"Yes\"\n } else {\n \"No\"\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1596416589, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/Kotlin/s220004782.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220004782", "user_id": "u542748657"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "fun main() {\n val x = readLine()!!.toInt()\n\n val answer = if (x >= 30) {\n \"Yes\"\n } else {\n \"No\"\n }\n\n println(answer)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 102, "memory_kb": 34452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s735628864", "group_id": "codeNet:p02595", "input_text": "fun main(args: Array) {\n val (n, d) = readLine()!!.split(' ').map { it.toInt() }\n var ans = 0\n repeat(n) {\n val (x, y) = readLine()!!.split(' ').map { it.toDouble() }\n if ( Math.sqrt(x*x + y*y) <= d.toDouble() ) ans++\n }\n println(ans)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1596416609, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/Kotlin/s735628864.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735628864", "user_id": "u288435405"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, d) = readLine()!!.split(' ').map { it.toInt() }\n var ans = 0\n repeat(n) {\n val (x, y) = readLine()!!.split(' ').map { it.toDouble() }\n if ( Math.sqrt(x*x + y*y) <= d.toDouble() ) ans++\n }\n println(ans)\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 275, "cpu_time_ms": 644, "memory_kb": 63096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s772444772", "group_id": "codeNet:p02596", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextInt()\n\n var l: Int\n if (k % 7 == 0) {\n l = 9 * k / 7\n } else {\n l = 9 * k\n }\n\n\n if (l % 2 == 0 || l % 5 == 0) {\n println(-1)\n return\n }\n\n var i = 1\n var tmp = 10L\n while (true) {\n if (tmp % l == 1L) {\n println(i)\n return\n }\n\n i++\n tmp = tmp % l * 10\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1596499025, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/Kotlin/s772444772.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772444772", "user_id": "u323522006"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextInt()\n\n var l: Int\n if (k % 7 == 0) {\n l = 9 * k / 7\n } else {\n l = 9 * k\n }\n\n\n if (l % 2 == 0 || l % 5 == 0) {\n println(-1)\n return\n }\n\n var i = 1\n var tmp = 10L\n while (true) {\n if (tmp % l == 1L) {\n println(i)\n return\n }\n\n i++\n tmp = tmp % l * 10\n }\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 400, "cpu_time_ms": 145, "memory_kb": 36340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s542533773", "group_id": "codeNet:p02596", "input_text": "\nfun main(args: Array) {\n val K = readLine()!!.toLong();\n val Kmax = Math.pow(\"10\".toDouble(), \"6\".toDouble())\n\n var container = \"7\"\n var containerValue = container.toDouble()\n val zeroD = \"0\".toDouble()\n while (containerValue < Kmax) {\n if(containerValue%K == zeroD) {\n println(container.length)\n return\n }\n container +=\"7\"\n containerValue = container.toDouble()\n }\n println(\"-1\")\n}", "language": "Kotlin", "metadata": {"date": 1596420922, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/Kotlin/s542533773.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s542533773", "user_id": "u852626707"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nfun main(args: Array) {\n val K = readLine()!!.toLong();\n val Kmax = Math.pow(\"10\".toDouble(), \"6\".toDouble())\n\n var container = \"7\"\n var containerValue = container.toDouble()\n val zeroD = \"0\".toDouble()\n while (containerValue < Kmax) {\n if(containerValue%K == zeroD) {\n println(container.length)\n return\n }\n container +=\"7\"\n containerValue = container.toDouble()\n }\n println(\"-1\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 465, "cpu_time_ms": 99, "memory_kb": 34672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s704521310", "group_id": "codeNet:p02596", "input_text": "import java.math.BigInteger\n\nfun main(args: Array) {\n val ks = readLine()!!\n if (ks.toInt() % 2 == 0 || ks.toInt() % 5 == 0) {\n println(-1)\n return\n }\n val k = BigInteger(ks)\n val nana = BigInteger(\"7\")\n\n var seven = BigInteger(\"7\")\n var ans = 1\n\n while (seven % k != BigInteger.ZERO) {\n seven = seven * BigInteger.TEN + nana\n ans++\n }\n\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1596420472, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/Kotlin/s704521310.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s704521310", "user_id": "u288435405"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.math.BigInteger\n\nfun main(args: Array) {\n val ks = readLine()!!\n if (ks.toInt() % 2 == 0 || ks.toInt() % 5 == 0) {\n println(-1)\n return\n }\n val k = BigInteger(ks)\n val nana = BigInteger(\"7\")\n\n var seven = BigInteger(\"7\")\n var ans = 1\n\n while (seven % k != BigInteger.ZERO) {\n seven = seven * BigInteger.TEN + nana\n ans++\n }\n\n\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 2207, "memory_kb": 53728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s231913665", "group_id": "codeNet:p02598", "input_text": "import kotlin.math.abs\nimport kotlin.math.floor\nimport kotlin.math.roundToInt\n\nprivate class E {\n fun solve() {\n val n = nextInt()\n val k = nextInt()\n val a = Array(n) { nextInt() }\n var l = 1.0\n var r = a.max()!!.toDouble()\n while (abs(r - l) > 1e-6) {\n val m = (r + l) / 2\n var count = 0\n for (x in a) {\n count += floor(x / m).toInt()\n }\n if (count > k) {\n l = m\n } else {\n r = m\n }\n }\n println(l.roundToInt())\n }\n\n var tokenBuffer = listOf()\n var bufferPosition = 0\n\n private fun checkBuffer() {\n if (bufferPosition == tokenBuffer.size) {\n tokenBuffer = nextLine().split(\" \")\n bufferPosition = 0\n }\n }\n\n fun nextLine() = readLine()!!\n fun nextInt(): Int {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toInt()\n }\n\n fun nextLong(): Long {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toLong()\n }\n\n fun nextDouble(): Double {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toDouble()\n }\n\n fun nextToken(): String {\n checkBuffer()\n return tokenBuffer[bufferPosition++]\n }\n}\n\nfun main() {\n val reader = E().solve()\n\n}\n", "language": "Kotlin", "metadata": {"date": 1596418068, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02598.html", "problem_id": "p02598", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02598/input.txt", "sample_output_relpath": "derived/input_output/data/p02598/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02598/Kotlin/s231913665.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s231913665", "user_id": "u331037015"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.floor\nimport kotlin.math.roundToInt\n\nprivate class E {\n fun solve() {\n val n = nextInt()\n val k = nextInt()\n val a = Array(n) { nextInt() }\n var l = 1.0\n var r = a.max()!!.toDouble()\n while (abs(r - l) > 1e-6) {\n val m = (r + l) / 2\n var count = 0\n for (x in a) {\n count += floor(x / m).toInt()\n }\n if (count > k) {\n l = m\n } else {\n r = m\n }\n }\n println(l.roundToInt())\n }\n\n var tokenBuffer = listOf()\n var bufferPosition = 0\n\n private fun checkBuffer() {\n if (bufferPosition == tokenBuffer.size) {\n tokenBuffer = nextLine().split(\" \")\n bufferPosition = 0\n }\n }\n\n fun nextLine() = readLine()!!\n fun nextInt(): Int {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toInt()\n }\n\n fun nextLong(): Long {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toLong()\n }\n\n fun nextDouble(): Double {\n checkBuffer()\n return tokenBuffer[bufferPosition++].toDouble()\n }\n\n fun nextToken(): String {\n checkBuffer()\n return tokenBuffer[bufferPosition++]\n }\n}\n\nfun main() {\n val reader = E().solve()\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0g>r\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var (red,green,blue) = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var k=scan.nextLine().toInt()\n var flag = false\n for(i in 1..k)\n {\n if(green<=red)\n green*=2\n else if(blue<=green)\n blue*=2\n\n if(green>red && blue>green)\n {\n flag=true\n break\n }\n }\n\n if(flag)\n println(\"Yes\")\n else\n println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1595726268, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02601.html", "problem_id": "p02601", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02601/input.txt", "sample_output_relpath": "derived/input_output/data/p02601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02601/Kotlin/s929506430.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929506430", "user_id": "u801179767"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n//b>g>r\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var (red,green,blue) = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var k=scan.nextLine().toInt()\n var flag = false\n for(i in 1..k)\n {\n if(green<=red)\n green*=2\n else if(blue<=green)\n blue*=2\n\n if(green>red && blue>green)\n {\n flag=true\n break\n }\n }\n\n if(flag)\n println(\"Yes\")\n else\n println(\"No\")\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "sample_input": "7 2 5\n3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02601", "source_text": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 539, "cpu_time_ms": 162, "memory_kb": 38480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s380891693", "group_id": "codeNet:p02602", "input_text": "import java.util.ArrayDeque\n\n//\n\nfun main() {\n msolutions2020c()\n}\n\nfun msolutions2020c() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toLong() }\n val queue = ArrayDeque()\n queue.addAll(a.subList(0, k))\n for (i in k until n) {\n val out = queue.poll()\n val next = a[i]\n if (next.toDouble() / out > 1.0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n queue.add(next)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1595726847, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02602/input.txt", "sample_output_relpath": "derived/input_output/data/p02602/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02602/Kotlin/s380891693.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s380891693", "user_id": "u628907033"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "import java.util.ArrayDeque\n\n//\n\nfun main() {\n msolutions2020c()\n}\n\nfun msolutions2020c() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toLong() }\n val queue = ArrayDeque()\n queue.addAll(a.subList(0, k))\n for (i in k until n) {\n val out = queue.poll()\n val next = a[i]\n if (next.toDouble() / out > 1.0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n queue.add(next)\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "sample_input": "5 3\n96 98 95 100 20\n"}, "reference_outputs": ["Yes\nNo\n"], "source_document_id": "p02602", "source_text": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 1191, "memory_kb": 73068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s600394286", "group_id": "codeNet:p02602", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var (x,y)=scan.nextLine().split(\" \").map{ it.trim().toLong() }.toTypedArray()\n var arr = scan.nextLine().split(\" \").map{ it.trim().toLong() }.toTypedArray()\n var prev = 0.toLong()\n\n for(i in 0..x-y)\n {\n var sum = 0.toLong()\n for(x in i..(i+y-1))\n sum+=arr[x.toInt()]\n if(prev>0)\n {\n if(sum>prev)\n println(\"Yes\")\n else\n println(\"No\")\n }\n prev=sum\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1595726027, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02602/input.txt", "sample_output_relpath": "derived/input_output/data/p02602/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02602/Kotlin/s600394286.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s600394286", "user_id": "u801179767"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var (x,y)=scan.nextLine().split(\" \").map{ it.trim().toLong() }.toTypedArray()\n var arr = scan.nextLine().split(\" \").map{ it.trim().toLong() }.toTypedArray()\n var prev = 0.toLong()\n\n for(i in 0..x-y)\n {\n var sum = 0.toLong()\n for(x in i..(i+y-1))\n sum+=arr[x.toInt()]\n if(prev>0)\n {\n if(sum>prev)\n println(\"Yes\")\n else\n println(\"No\")\n }\n prev=sum\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "sample_input": "5 3\n96 98 95 100 20\n"}, "reference_outputs": ["Yes\nNo\n"], "source_document_id": "p02602", "source_text": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 563, "cpu_time_ms": 2209, "memory_kb": 94740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s969032237", "group_id": "codeNet:p02602", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n var sum = 1L\n var prev = 1L\n repeat(n) {\n sum *= a[it]\n if (it >= k) {\n sum /= a[it-k]\n\n if (prev < sum) println(\"Yes\")\n else println(\"No\")\n }\n prev = sum\n }\n}", "language": "Kotlin", "metadata": {"date": 1595725982, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02602/input.txt", "sample_output_relpath": "derived/input_output/data/p02602/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02602/Kotlin/s969032237.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s969032237", "user_id": "u288435405"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n var sum = 1L\n var prev = 1L\n repeat(n) {\n sum *= a[it]\n if (it >= k) {\n sum /= a[it-k]\n\n if (prev < sum) println(\"Yes\")\n else println(\"No\")\n }\n prev = sum\n }\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "sample_input": "5 3\n96 98 95 100 20\n"}, "reference_outputs": ["Yes\nNo\n"], "source_document_id": "p02602", "source_text": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 381, "cpu_time_ms": 1173, "memory_kb": 68268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s069460653", "group_id": "codeNet:p02603", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var kotlin=scan.nextLine().toInt()\n var arr = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n\n var buy = 0\n var money = 1000\n var count = 0\n var remain = 0\n var xsell = Int.MAX_VALUE\n for(i in 0..arr.size-2)\n {\n var x = arr[i]\n var y = arr[i+1]\n\n if(count==0 && xbuy && count>0 && x>y)\n {\n money = (count*x) + remain\n count = 0\n // println(\"$x sell $money $count $remain\")\n xsell = x\n }\n }\n\n if (arr[arr.lastIndex]>buy && count>0)\n {\n money = (count*arr[arr.lastIndex]) + remain\n }\n\n if(money==(arr[0]*count))\n println(\"1000\")\n else\n println(money)\n}\n", "language": "Kotlin", "metadata": {"date": 1595727873, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02603/input.txt", "sample_output_relpath": "derived/input_output/data/p02603/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02603/Kotlin/s069460653.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s069460653", "user_id": "u801179767"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var kotlin=scan.nextLine().toInt()\n var arr = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n\n var buy = 0\n var money = 1000\n var count = 0\n var remain = 0\n var xsell = Int.MAX_VALUE\n for(i in 0..arr.size-2)\n {\n var x = arr[i]\n var y = arr[i+1]\n\n if(count==0 && xbuy && count>0 && x>y)\n {\n money = (count*x) + remain\n count = 0\n // println(\"$x sell $money $count $remain\")\n xsell = x\n }\n }\n\n if (arr[arr.lastIndex]>buy && count>0)\n {\n money = (count*arr[arr.lastIndex]) + remain\n }\n\n if(money==(arr[0]*count))\n println(\"1000\")\n else\n println(money)\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "sample_input": "7\n100 130 130 130 115 115 150\n"}, "reference_outputs": ["1685\n"], "source_document_id": "p02603", "source_text": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 997, "cpu_time_ms": 180, "memory_kb": 42176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s874152812", "group_id": "codeNet:p02603", "input_text": "import java.io.BufferedReader\nimport kotlin.math.max\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val n = br.readInt()\n val a = LongArray(n) { br.readInt().toLong() }\n var curMoney = 1000L\n var curStocks = 0L\n var lastPrice = 200L\n var boughtPrice = 0L\n\n for (x in 0 until n) {\n val price = a[x]\n if (curStocks == 0L) {\n if (price > lastPrice) {\n curStocks = curMoney / lastPrice\n curMoney -= lastPrice * curStocks\n boughtPrice = lastPrice\n }\n } else if (price < lastPrice) {\n curMoney += curStocks * lastPrice\n curStocks = 0\n }\n lastPrice = price\n\n }\n if (curStocks != 0L) {\n curMoney += curStocks * max(boughtPrice, lastPrice)\n }\n print(curMoney)\n}\n\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\n}", "language": "Kotlin", "metadata": {"date": 1595726852, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02603/input.txt", "sample_output_relpath": "derived/input_output/data/p02603/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02603/Kotlin/s874152812.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874152812", "user_id": "u669089376"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "import java.io.BufferedReader\nimport kotlin.math.max\n\nfun main() {\n val br = System.`in`.bufferedReader()\n val n = br.readInt()\n val a = LongArray(n) { br.readInt().toLong() }\n var curMoney = 1000L\n var curStocks = 0L\n var lastPrice = 200L\n var boughtPrice = 0L\n\n for (x in 0 until n) {\n val price = a[x]\n if (curStocks == 0L) {\n if (price > lastPrice) {\n curStocks = curMoney / lastPrice\n curMoney -= lastPrice * curStocks\n boughtPrice = lastPrice\n }\n } else if (price < lastPrice) {\n curMoney += curStocks * lastPrice\n curStocks = 0\n }\n lastPrice = price\n\n }\n if (curStocks != 0L) {\n curMoney += curStocks * max(boughtPrice, lastPrice)\n }\n print(curMoney)\n}\n\n\nprivate const val SPACE_INT = ' '.toInt()\nprivate const val ZERO_INT = '0'.toInt()\nprivate const val NL_INT = '\\n'.toInt()\n\nprivate fun BufferedReader.readInt(): Int {\n var ret = read()\n while (ret <= SPACE_INT) {\n ret = read()\n }\n val neg = ret == '-'.toInt()\n if (neg) {\n ret = read()\n }\n ret -= ZERO_INT\n var read = read()\n while (read >= ZERO_INT) {\n ret *= 10\n ret += read - ZERO_INT\n read = read()\n }\n\n while (read <= SPACE_INT && read != -1 && read != NL_INT) {\n mark(1)\n read = read()\n }\n if (read > SPACE_INT) {\n reset()\n }\n return if (neg) -ret else ret\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "sample_input": "7\n100 130 130 130 115 115 150\n"}, "reference_outputs": ["1685\n"], "source_document_id": "p02603", "source_text": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1495, "cpu_time_ms": 103, "memory_kb": 34272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s253051525", "group_id": "codeNet:p02605", "input_text": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\t//sort left to right, bot to top\n\tval n = f.readLine().toInt()\n\tval points = Array(n){\n\t\tval (a,b,c) = f.readLine().split(\" \")\n\t\tPoint(a.toInt(),b.toInt(),c.single())\n\t}.sortedWith(compareBy({it.x},{it.y}))\n\n\tval MAX = 4000000\n\tvar answer = MAX\n\n\tval cols = HashMap>()\n\tval rows = HashMap>()\n\n\t//diagonal determined by y-x\n\tval ulminus = HashMap>()\n\tval rdminus = HashMap>()\n\n\t//diagonal determined by x+y\n\tval ruplus = HashMap>()\n\tval dlplus = HashMap>()\n\n\tfor(k in 0 until n){\n\t\tval p = points[k]\n\t\tif(p.d == 'U'){\n\t\t\tif(cols.containsKey(p.x)){\n\t\t\t\tcols[p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tcols.put(p.x,pq)\n\t\t\t}\n\n\t\t\tif(ulminus.containsKey(p.y-p.x)){\n\t\t\t\tulminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tulminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(ruplus.containsKey(p.y+p.x)){\n\t\t\t\truplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\truplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t} else if(p.d == 'D'){\n\t\t\tif(cols.containsKey(p.x)){\n\t\t\t\tcols[p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tcols.put(p.x,pq)\n\t\t\t}\n\n\t\t\tif(rdminus.containsKey(p.y-p.x)){\n\t\t\t\trdminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trdminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(dlplus.containsKey(p.y+p.x)){\n\t\t\t\tdlplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tdlplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t} else if(p.d == 'L'){\n\t\t\tif(rows.containsKey(p.y)){\n\t\t\t\trows[p.y]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trows.put(p.y,pq)\n\t\t\t}\n\n\t\t\tif(ulminus.containsKey(p.y-p.x)){\n\t\t\t\tulminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tulminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(dlplus.containsKey(p.y+p.x)){\n\t\t\t\tdlplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tdlplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t} else if(p.d == 'R'){\n\t\t\tif(rows.containsKey(p.y)){\n\t\t\t\trows[p.y]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trows.put(p.y,pq)\n\t\t\t}\n\n\t\t\tif(rdminus.containsKey(p.y-p.x)){\n\t\t\t\trdminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trdminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(ruplus.containsKey(p.y+p.x)){\n\t\t\t\truplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\truplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t}\n\t}\n\n\tfun dist(p1 : Point, p2 : Point) : Int{\n\t\treturn max(abs(p1.x-p2.x),abs(p1.y-p2.y))\n\t}\n\n\tfun calc(li : MutableList,first : Char, second : Char) : Int{\n\n\t\tvar seenprev = false\n\t\tvar prev = Point(0,0,second)\n\n\t\tvar ret = 3*MAX\n\n\t\tfor(p in li){\n\t\t\tif(p.d == first){\n\t\t\t\tseenprev = true\n\t\t\t\tprev = p\n\t\t\t} else if(p.d == second){\n\t\t\t\tif(seenprev){\n\t\t\t\t\tret = min(ret,dist(p,prev))\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\treturn ret\n\t}\n\n\t//cols\n\tfor(i in cols.keys){\n\t\tanswer = min(answer,calc(cols[i]!!,'U','D')*5)\n\t}\n\n\t//rows\n\tfor(i in rows.keys){\n\t\tanswer = min(answer,calc(rows[i]!!,'R','L')*5)\n\t}\n\n\t//ulminus\n\tfor(i in ulminus.keys){\n\t\tanswer = min(answer,calc(ulminus[i]!!,'U','L')*10)\n\t}\n\n\t//drminus\n\tfor(i in rdminus.keys){\n\t\tanswer = min(answer,calc(rdminus[i]!!,'R','D')*10)\n\t}\n\n\t//ruplus\n\tfor(i in ruplus.keys){\n\t\tanswer = min(answer,calc(ruplus[i]!!,'R','U')*10)\n\t}\n\n\t//dlplus\n\tfor(i in dlplus.keys){\n\t\tanswer = min(answer,calc(dlplus[i]!!,'D','L')*10)\n\t}\n\n\tif(answer == MAX){\n\t\tprintln(\"SAFE\")\n\t} else {\n\t\tprintln(answer)\n\t}\n\n}\ndata class Point(val x : Int, val y : Int, val d : Char)\n", "language": "Kotlin", "metadata": {"date": 1595750295, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02605.html", "problem_id": "p02605", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02605/input.txt", "sample_output_relpath": "derived/input_output/data/p02605/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02605/Kotlin/s253051525.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253051525", "user_id": "u140923503"}, "prompt_components": {"gold_output": "230\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\t//sort left to right, bot to top\n\tval n = f.readLine().toInt()\n\tval points = Array(n){\n\t\tval (a,b,c) = f.readLine().split(\" \")\n\t\tPoint(a.toInt(),b.toInt(),c.single())\n\t}.sortedWith(compareBy({it.x},{it.y}))\n\n\tval MAX = 4000000\n\tvar answer = MAX\n\n\tval cols = HashMap>()\n\tval rows = HashMap>()\n\n\t//diagonal determined by y-x\n\tval ulminus = HashMap>()\n\tval rdminus = HashMap>()\n\n\t//diagonal determined by x+y\n\tval ruplus = HashMap>()\n\tval dlplus = HashMap>()\n\n\tfor(k in 0 until n){\n\t\tval p = points[k]\n\t\tif(p.d == 'U'){\n\t\t\tif(cols.containsKey(p.x)){\n\t\t\t\tcols[p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tcols.put(p.x,pq)\n\t\t\t}\n\n\t\t\tif(ulminus.containsKey(p.y-p.x)){\n\t\t\t\tulminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tulminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(ruplus.containsKey(p.y+p.x)){\n\t\t\t\truplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\truplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t} else if(p.d == 'D'){\n\t\t\tif(cols.containsKey(p.x)){\n\t\t\t\tcols[p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tcols.put(p.x,pq)\n\t\t\t}\n\n\t\t\tif(rdminus.containsKey(p.y-p.x)){\n\t\t\t\trdminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trdminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(dlplus.containsKey(p.y+p.x)){\n\t\t\t\tdlplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tdlplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t} else if(p.d == 'L'){\n\t\t\tif(rows.containsKey(p.y)){\n\t\t\t\trows[p.y]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trows.put(p.y,pq)\n\t\t\t}\n\n\t\t\tif(ulminus.containsKey(p.y-p.x)){\n\t\t\t\tulminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tulminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(dlplus.containsKey(p.y+p.x)){\n\t\t\t\tdlplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\tdlplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t} else if(p.d == 'R'){\n\t\t\tif(rows.containsKey(p.y)){\n\t\t\t\trows[p.y]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trows.put(p.y,pq)\n\t\t\t}\n\n\t\t\tif(rdminus.containsKey(p.y-p.x)){\n\t\t\t\trdminus[p.y-p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\trdminus.put(p.y-p.x,pq)\n\t\t\t}\n\n\t\t\tif(ruplus.containsKey(p.y+p.x)){\n\t\t\t\truplus[p.y+p.x]!!.add(p)\n\t\t\t} else {\n\t\t\t\tval pq = mutableListOf()\n\t\t\t\tpq.add(p)\n\t\t\t\truplus.put(p.y+p.x,pq)\n\t\t\t}\n\t\t}\n\t}\n\n\tfun dist(p1 : Point, p2 : Point) : Int{\n\t\treturn max(abs(p1.x-p2.x),abs(p1.y-p2.y))\n\t}\n\n\tfun calc(li : MutableList,first : Char, second : Char) : Int{\n\n\t\tvar seenprev = false\n\t\tvar prev = Point(0,0,second)\n\n\t\tvar ret = 3*MAX\n\n\t\tfor(p in li){\n\t\t\tif(p.d == first){\n\t\t\t\tseenprev = true\n\t\t\t\tprev = p\n\t\t\t} else if(p.d == second){\n\t\t\t\tif(seenprev){\n\t\t\t\t\tret = min(ret,dist(p,prev))\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\treturn ret\n\t}\n\n\t//cols\n\tfor(i in cols.keys){\n\t\tanswer = min(answer,calc(cols[i]!!,'U','D')*5)\n\t}\n\n\t//rows\n\tfor(i in rows.keys){\n\t\tanswer = min(answer,calc(rows[i]!!,'R','L')*5)\n\t}\n\n\t//ulminus\n\tfor(i in ulminus.keys){\n\t\tanswer = min(answer,calc(ulminus[i]!!,'U','L')*10)\n\t}\n\n\t//drminus\n\tfor(i in rdminus.keys){\n\t\tanswer = min(answer,calc(rdminus[i]!!,'R','D')*10)\n\t}\n\n\t//ruplus\n\tfor(i in ruplus.keys){\n\t\tanswer = min(answer,calc(ruplus[i]!!,'R','U')*10)\n\t}\n\n\t//dlplus\n\tfor(i in dlplus.keys){\n\t\tanswer = min(answer,calc(dlplus[i]!!,'D','L')*10)\n\t}\n\n\tif(answer == MAX){\n\t\tprintln(\"SAFE\")\n\t} else {\n\t\tprintln(answer)\n\t}\n\n}\ndata class Point(val x : Int, val y : Int, val d : Char)\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\n\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows:\n\nif U_i is U, it flies in the positive y direction;\n\nif U_i is R, it flies in the positive x direction;\n\nif U_i is D, it flies in the negative y direction;\n\nif U_i is L, it flies in the negative x direction.\n\nTo help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now.\n\nIf there is such a pair, find the number of seconds after which the first collision will happen.\n\nWe assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n0 \\leq X_i, Y_i \\leq 200000\n\nU_i is U, R, D, or L.\n\nThe current positions of the N airplanes, (X_i, Y_i), are all distinct.\n\nN, X_i, and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 U_1\nX_2 Y_2 U_2\nX_3 Y_3 U_3\n:\nX_N Y_N U_N\n\nOutput\n\nIf there is a pair of airplanes that will collide with each other if they keep flying as they are now, print an integer representing the number of seconds after which the first collision will happen.\n\nIf there is no such pair, print SAFE.\n\nSample Input 1\n\n2\n11 1 U\n11 47 D\n\nSample Output 1\n\n230\n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2 will reach the coordinates (11, 24) simultaneously and collide.\n\nSample Input 2\n\n4\n20 30 U\n30 20 R\n20 10 D\n10 20 L\n\nSample Output 2\n\nSAFE\n\nNo pair of airplanes will collide.\n\nSample Input 3\n\n8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L\n\nSample Output 3\n\n100", "sample_input": "2\n11 1 U\n11 47 D\n"}, "reference_outputs": ["230\n"], "source_document_id": "p02605", "source_text": "Score: 600 points\n\nProblem Statement\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\n\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows:\n\nif U_i is U, it flies in the positive y direction;\n\nif U_i is R, it flies in the positive x direction;\n\nif U_i is D, it flies in the negative y direction;\n\nif U_i is L, it flies in the negative x direction.\n\nTo help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now.\n\nIf there is such a pair, find the number of seconds after which the first collision will happen.\n\nWe assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n0 \\leq X_i, Y_i \\leq 200000\n\nU_i is U, R, D, or L.\n\nThe current positions of the N airplanes, (X_i, Y_i), are all distinct.\n\nN, X_i, and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 U_1\nX_2 Y_2 U_2\nX_3 Y_3 U_3\n:\nX_N Y_N U_N\n\nOutput\n\nIf there is a pair of airplanes that will collide with each other if they keep flying as they are now, print an integer representing the number of seconds after which the first collision will happen.\n\nIf there is no such pair, print SAFE.\n\nSample Input 1\n\n2\n11 1 U\n11 47 D\n\nSample Output 1\n\n230\n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2 will reach the coordinates (11, 24) simultaneously and collide.\n\nSample Input 2\n\n4\n20 30 U\n30 20 R\n20 10 D\n10 20 L\n\nSample Output 2\n\nSAFE\n\nNo pair of airplanes will collide.\n\nSample Input 3\n\n8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L\n\nSample Output 3\n\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3808, "cpu_time_ms": 1805, "memory_kb": 182308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s277957390", "group_id": "codeNet:p02607", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nfun main() {\n val N = rd.readInt()\n val A = rd.readIntArray()\n\n var ans = 0\n for (i in 0 until N step 2) {\n if (A[i]%2 == 1) ans++\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"168\", \"b\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "language": "Kotlin", "metadata": {"date": 1594589659, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/Kotlin/s277957390.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277957390", "user_id": "u404244809"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nfun main() {\n val N = rd.readInt()\n val A = rd.readIntArray()\n\n var ans = 0\n for (i in 0 until N step 2) {\n if (A[i]%2 == 1) ans++\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"168\", \"b\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1337, "cpu_time_ms": 128, "memory_kb": 36768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s161642052", "group_id": "codeNet:p02607", "input_text": "fun main() {\n // 文字列\n val str = readLine()!!\n // 数値\n// val int =readLine()!!.toInt()\n // 行\n val list = readLine()!!.split(\" \").map (String::toInt )\n// val (a,b) = readLine()!!.split(\" \").map(String::toInt)\n\n var sum=0\n var ii=1\n for (i in list){\n if (i==0) continue\n ii++\n if (ii%2==1){\n if (i%2==1){\n sum++\n }\n }\n }\n\n print(sum)\n}", "language": "Kotlin", "metadata": {"date": 1594517194, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/Kotlin/s161642052.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s161642052", "user_id": "u826331398"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n // 文字列\n val str = readLine()!!\n // 数値\n// val int =readLine()!!.toInt()\n // 行\n val list = readLine()!!.split(\" \").map (String::toInt )\n// val (a,b) = readLine()!!.split(\" \").map(String::toInt)\n\n var sum=0\n var ii=1\n for (i in list){\n if (i==0) continue\n ii++\n if (ii%2==1){\n if (i%2==1){\n sum++\n }\n }\n }\n\n print(sum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 444, "cpu_time_ms": 113, "memory_kb": 36488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s903268657", "group_id": "codeNet:p02608", "input_text": "import kotlin.math.*\nfun main() {\n// 文字列\n// val str = readLine()!!\n// 数値\n val n = readLine()!!.toInt()\n// 行\n// val list = readLine()!!.split(\" \").map(String::toInt)\n// val (a,b,c) = readLine()!!.split(\" \").map(String::toInt)\n\n// val (a,b,c)=\"0 0 0\".split(\" \").map(String::toInt)\n\n val m= sqrt(n.toDouble()).toInt()\n for (o in 1..n) {\n var an = 0\n for (i in 1..m) {\n for (j in 1..m) {\n for (k in 1..m) {\n val sum = i * i + j * j + k * k + i * j + j * k + k * i\n if (o == sum) {\n an++\n }\n }\n }\n }\n println(an)\n\n }\n\n\n\n// print(str)\n}\n", "language": "Kotlin", "metadata": {"date": 1594524703, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/Kotlin/s903268657.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s903268657", "user_id": "u826331398"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "import kotlin.math.*\nfun main() {\n// 文字列\n// val str = readLine()!!\n// 数値\n val n = readLine()!!.toInt()\n// 行\n// val list = readLine()!!.split(\" \").map(String::toInt)\n// val (a,b,c) = readLine()!!.split(\" \").map(String::toInt)\n\n// val (a,b,c)=\"0 0 0\".split(\" \").map(String::toInt)\n\n val m= sqrt(n.toDouble()).toInt()\n for (o in 1..n) {\n var an = 0\n for (i in 1..m) {\n for (j in 1..m) {\n for (k in 1..m) {\n val sum = i * i + j * j + k * k + i * j + j * k + k * i\n if (o == sum) {\n an++\n }\n }\n }\n }\n println(an)\n\n }\n\n\n\n// print(str)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 730, "cpu_time_ms": 2207, "memory_kb": 35764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s445762829", "group_id": "codeNet:p02609", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n //val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val X = read()\n\n val p = X.count { it == '1' }\n\n val F = IntArray(p+1)\n for(i in 1..p) {\n F[i] = F[i % i.popCount] + 1\n }\n\n val A = placeValueArray(p+1, n)\n val B = if(p <= 1) null else placeValueArray(p-1, n)\n val xa = (0 until n).sumByLong { i ->\n if(X[i] == '1') A[i].toLong() else 0L\n } modulo p+1\n val xb = if(B == null) 0 else (0 until n).sumByLong { i ->\n if(X[i] == '1') B[i].toLong() else 0L\n } modulo p-1\n\n for(i in 0 until n) {\n val ans = when {\n X[i] == '0' -> {\n val r = xa + A[i] modulo p+1\n F[r] + 1\n }\n B == null -> 0\n else -> {\n val r = xb - B[i] modulo p-1\n F[r] + 1\n }\n }\n\n println(ans)\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\ninline val Int.popCount get() = Integer.bitCount(this)\n\nfun placeValueArray(mod: Int, n: Int): IntArray {\n val ans = IntArray(n)\n ans[n-1] = 1\n\n for(i in n-2 downTo 0) {\n ans[i] = (ans[i+1] shl 1) % mod\n }\n\n return ans\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1594591449, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02609/input.txt", "sample_output_relpath": "derived/input_output/data/p02609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02609/Kotlin/s445762829.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445762829", "user_id": "u596111103"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n //val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val X = read()\n\n val p = X.count { it == '1' }\n\n val F = IntArray(p+1)\n for(i in 1..p) {\n F[i] = F[i % i.popCount] + 1\n }\n\n val A = placeValueArray(p+1, n)\n val B = if(p <= 1) null else placeValueArray(p-1, n)\n val xa = (0 until n).sumByLong { i ->\n if(X[i] == '1') A[i].toLong() else 0L\n } modulo p+1\n val xb = if(B == null) 0 else (0 until n).sumByLong { i ->\n if(X[i] == '1') B[i].toLong() else 0L\n } modulo p-1\n\n for(i in 0 until n) {\n val ans = when {\n X[i] == '0' -> {\n val r = xa + A[i] modulo p+1\n F[r] + 1\n }\n B == null -> 0\n else -> {\n val r = xb - B[i] modulo p-1\n F[r] + 1\n }\n }\n\n println(ans)\n }\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ninfix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }\ninfix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()\ninline val Int.popCount get() = Integer.bitCount(this)\n\nfun placeValueArray(mod: Int, n: Int): IntArray {\n val ans = IntArray(n)\n ans[n-1] = 1\n\n for(i in n-2 downTo 0) {\n ans[i] = (ans[i+1] shl 1) % mod\n }\n\n return ans\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "sample_input": "3\n011\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02609", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5796, "cpu_time_ms": 293, "memory_kb": 50108}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s113013791", "group_id": "codeNet:p02609", "input_text": "fun main() = Thread(null, ::aising2020d, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun aising2020d() {\n val n = readLine()!!.toInt()\n val x = readLine()!!\n\n val baseBitCount = x.count { it == '1' }.toLong()\n val bitCountToModded = mutableMapOf()\n\n for (bitCount in baseBitCount - 1..baseBitCount + 1) {\n if (bitCount == 0L) {\n bitCountToModded[bitCount] = 0\n continue\n }\n\n var modByBitCount = 0L\n for ((index, c) in x.withIndex()) {\n if (c == '1') {\n modByBitCount += (2L).modPow(n - index - 1L, bitCount)\n modByBitCount %= bitCount\n }\n }\n bitCountToModded[bitCount] = modByBitCount\n }\n\n val answer = StringBuilder()\n\n for (i in 0 until n) {\n val currBitCount = baseBitCount + if (x[i] == '0') 1 else -1\n\n if (currBitCount == 0L) {\n answer.appendln(0)\n continue\n }\n\n val modPow = (2L).modPow(n - i - 1L, currBitCount)\n var modded = bitCountToModded[currBitCount]!! + if (x[i] == '0') modPow else -modPow\n modded += currBitCount\n modded %= currBitCount\n\n var currX = modded\n var count = 1\n\n while (currX > 0) {\n currX %= currX.countOneBits()\n count++\n }\n\n answer.appendln(count)\n }\n\n print(answer)\n}\n\nprivate fun Long.modPow(p: Long, m: Long): Long {\n var x = this % m\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n return result\n}\n", "language": "Kotlin", "metadata": {"date": 1594573500, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02609/input.txt", "sample_output_relpath": "derived/input_output/data/p02609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02609/Kotlin/s113013791.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s113013791", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "fun main() = Thread(null, ::aising2020d, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun aising2020d() {\n val n = readLine()!!.toInt()\n val x = readLine()!!\n\n val baseBitCount = x.count { it == '1' }.toLong()\n val bitCountToModded = mutableMapOf()\n\n for (bitCount in baseBitCount - 1..baseBitCount + 1) {\n if (bitCount == 0L) {\n bitCountToModded[bitCount] = 0\n continue\n }\n\n var modByBitCount = 0L\n for ((index, c) in x.withIndex()) {\n if (c == '1') {\n modByBitCount += (2L).modPow(n - index - 1L, bitCount)\n modByBitCount %= bitCount\n }\n }\n bitCountToModded[bitCount] = modByBitCount\n }\n\n val answer = StringBuilder()\n\n for (i in 0 until n) {\n val currBitCount = baseBitCount + if (x[i] == '0') 1 else -1\n\n if (currBitCount == 0L) {\n answer.appendln(0)\n continue\n }\n\n val modPow = (2L).modPow(n - i - 1L, currBitCount)\n var modded = bitCountToModded[currBitCount]!! + if (x[i] == '0') modPow else -modPow\n modded += currBitCount\n modded %= currBitCount\n\n var currX = modded\n var count = 1\n\n while (currX > 0) {\n currX %= currX.countOneBits()\n count++\n }\n\n answer.appendln(count)\n }\n\n print(answer)\n}\n\nprivate fun Long.modPow(p: Long, m: Long): Long {\n var x = this % m\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n return result\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "sample_input": "3\n011\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02609", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1681, "cpu_time_ms": 523, "memory_kb": 46964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s454789137", "group_id": "codeNet:p02609", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun next(X: IntArray, div: Int): Int {\n var ans = 0\n var d = 1\n for (i in X.count() - 1 downTo 0) {\n if (X[i] == 1) {\n ans += d % div\n ans %= div\n }\n d *= 2\n d %= div\n }\n return ans\n }\n\n fun bits(n: Int): Int {\n var i = n\n var b = 0\n do {\n b += i and 1\n i /= 2\n } while (i > 0)\n return b\n }\n\n fun next(X: Int): Int {\n var ans = 0\n var d = 1\n val div = bits(X)\n var x = X\n while (x > 0) {\n if (x and 1 == 1) {\n ans += d % div\n ans %= div\n }\n d *= 2\n d %= div\n x /= 2\n }\n return ans\n }\n\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val X = sc.next().map { it.toInt() - 48 }.toIntArray()\n\n val n = IntArray(100001)\n for (i in 1..100000) {\n n[i] = next(i)\n }\n\n val div = X.count { it == 1 }\n val x1 = next(X, div - 1)\n val x2 = next(X, div + 1)\n val second = IntArray(N)\n var d = 1\n for (i in N - 1 downTo 0) {\n if (X[i] == 1) {\n // 1 -> 0\n second[i] = x1 - d % (div - 1)\n second[i] += div - 1\n second[i] %= div - 1\n } else {\n // 0 -> 1\n second[i] = x2 + d % (div + 1)\n second[i] %= div + 1\n }\n d *= 2\n }\n\n for (i in 0 until N) {\n var ans = 1\n var x = second[i]\n while (x > 0) {\n x = n[x]\n ans++\n }\n pw.println(ans)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1594521322, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02609/input.txt", "sample_output_relpath": "derived/input_output/data/p02609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02609/Kotlin/s454789137.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s454789137", "user_id": "u297767059"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun next(X: IntArray, div: Int): Int {\n var ans = 0\n var d = 1\n for (i in X.count() - 1 downTo 0) {\n if (X[i] == 1) {\n ans += d % div\n ans %= div\n }\n d *= 2\n d %= div\n }\n return ans\n }\n\n fun bits(n: Int): Int {\n var i = n\n var b = 0\n do {\n b += i and 1\n i /= 2\n } while (i > 0)\n return b\n }\n\n fun next(X: Int): Int {\n var ans = 0\n var d = 1\n val div = bits(X)\n var x = X\n while (x > 0) {\n if (x and 1 == 1) {\n ans += d % div\n ans %= div\n }\n d *= 2\n d %= div\n x /= 2\n }\n return ans\n }\n\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val X = sc.next().map { it.toInt() - 48 }.toIntArray()\n\n val n = IntArray(100001)\n for (i in 1..100000) {\n n[i] = next(i)\n }\n\n val div = X.count { it == 1 }\n val x1 = next(X, div - 1)\n val x2 = next(X, div + 1)\n val second = IntArray(N)\n var d = 1\n for (i in N - 1 downTo 0) {\n if (X[i] == 1) {\n // 1 -> 0\n second[i] = x1 - d % (div - 1)\n second[i] += div - 1\n second[i] %= div - 1\n } else {\n // 0 -> 1\n second[i] = x2 + d % (div + 1)\n second[i] %= div + 1\n }\n d *= 2\n }\n\n for (i in 0 until N) {\n var ans = 1\n var x = second[i]\n while (x > 0) {\n x = n[x]\n ans++\n }\n pw.println(ans)\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "sample_input": "3\n011\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02609", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1998, "cpu_time_ms": 437, "memory_kb": 56928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s912476225", "group_id": "codeNet:p02613", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n\n val sMap = HashMap()\n for (i in 0 until n) {\n val s = readLine()!!\n\n sMap[s] = (sMap[s] ?: 0) + 1\n }\n sMap[\"AC\"] = sMap[\"AC\"] ?: 0\n sMap[\"WA\"] = sMap[\"WA\"] ?: 0\n sMap[\"TLE\"] = sMap[\"TLE\"] ?: 0\n sMap[\"RE\"] = sMap[\"RE\"] ?: 0\n\n println(\"AC x \" + sMap[\"AC\"])\n println(\"WA x \" + sMap[\"WA\"])\n println(\"TLE x \" + sMap[\"TLE\"])\n println(\"RE x \" + sMap[\"RE\"])\n}", "language": "Kotlin", "metadata": {"date": 1593998090, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Kotlin/s912476225.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912476225", "user_id": "u542748657"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n\n val sMap = HashMap()\n for (i in 0 until n) {\n val s = readLine()!!\n\n sMap[s] = (sMap[s] ?: 0) + 1\n }\n sMap[\"AC\"] = sMap[\"AC\"] ?: 0\n sMap[\"WA\"] = sMap[\"WA\"] ?: 0\n sMap[\"TLE\"] = sMap[\"TLE\"] ?: 0\n sMap[\"RE\"] = sMap[\"RE\"] ?: 0\n\n println(\"AC x \" + sMap[\"AC\"])\n println(\"WA x \" + sMap[\"WA\"])\n println(\"TLE x \" + sMap[\"TLE\"])\n println(\"RE x \" + sMap[\"RE\"])\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 459, "cpu_time_ms": 291, "memory_kb": 57684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s174390987", "group_id": "codeNet:p02613", "input_text": "fun main() {\n val num = readLine()!!.toInt()\n var ac = 0\n var wa = 0\n var tle = 0\n var re = 0\n repeat(num) {\n when (readLine()!![0]) {\n 'A' -> ac++\n 'W' -> wa++\n 'T' -> tle++\n 'R' -> re++\n }\n }\n println(\"AC x $ac\")\n println(\"WA x $wa\")\n println(\"TLE x $tle\")\n println(\"RE x $re\")\n}", "language": "Kotlin", "metadata": {"date": 1593997708, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Kotlin/s174390987.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s174390987", "user_id": "u108745033"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "fun main() {\n val num = readLine()!!.toInt()\n var ac = 0\n var wa = 0\n var tle = 0\n var re = 0\n repeat(num) {\n when (readLine()!![0]) {\n 'A' -> ac++\n 'W' -> wa++\n 'T' -> tle++\n 'R' -> re++\n }\n }\n println(\"AC x $ac\")\n println(\"WA x $wa\")\n println(\"TLE x $tle\")\n println(\"RE x $re\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 372, "cpu_time_ms": 261, "memory_kb": 56672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s215534593", "group_id": "codeNet:p02613", "input_text": "fun main(args: Array) {\n val n = readInt()\n\n var ac = 0\n var wa = 0\n var tle = 0\n var re = 0\n repeat(n) {\n val s = readString()\n when(s) {\n \"AC\" -> ac++\n \"WA\" -> wa++\n \"TLE\" ->tle++\n \"RE\" -> re++\n }\n }\n println(\"AC x $ac\")\n println(\"WA x $wa\")\n println(\"TLE x $tle\")\n println(\"RE x $re\")\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1593997527, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Kotlin/s215534593.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215534593", "user_id": "u697467902"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInt()\n\n var ac = 0\n var wa = 0\n var tle = 0\n var re = 0\n repeat(n) {\n val s = readString()\n when(s) {\n \"AC\" -> ac++\n \"WA\" -> wa++\n \"TLE\" ->tle++\n \"RE\" -> re++\n }\n }\n println(\"AC x $ac\")\n println(\"WA x $wa\")\n println(\"TLE x $tle\")\n println(\"RE x $re\")\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 688, "cpu_time_ms": 282, "memory_kb": 56704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s765102390", "group_id": "codeNet:p02614", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val H = sc.next().toInt()\n val W = sc.next().toInt()\n val K = sc.next().toInt()\n val C = Array(H) { sc.next().toCharArray().map { it == '#' }.toBooleanArray() }\n var hmax = 1\n repeat(H) { hmax *= 2 }\n var wmax = 1\n repeat(W) { wmax *= 2 }\n var ans = 0L\n for (hr in 0 until hmax) for (wr in 0 until wmax) {\n var n = 0\n loop@ for (h in 0 until H) for (w in 0 until W) {\n if (C[h][w] && (hr and (1 shl h)) == 0 && (wr and (1 shl w)) == 0) {\n n++\n if (n > K) break@loop\n }\n }\n if (n == K) {\n //dprint(\"($hr, $wr) : $n\")\n ans++\n }\n }\n pw.println(ans)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1593998276, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/Kotlin/s765102390.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765102390", "user_id": "u297767059"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val H = sc.next().toInt()\n val W = sc.next().toInt()\n val K = sc.next().toInt()\n val C = Array(H) { sc.next().toCharArray().map { it == '#' }.toBooleanArray() }\n var hmax = 1\n repeat(H) { hmax *= 2 }\n var wmax = 1\n repeat(W) { wmax *= 2 }\n var ans = 0L\n for (hr in 0 until hmax) for (wr in 0 until wmax) {\n var n = 0\n loop@ for (h in 0 until H) for (w in 0 until W) {\n if (C[h][w] && (hr and (1 shl h)) == 0 && (wr and (1 shl w)) == 0) {\n n++\n if (n > K) break@loop\n }\n }\n if (n == K) {\n //dprint(\"($hr, $wr) : $n\")\n ans++\n }\n }\n pw.println(ans)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1022, "cpu_time_ms": 172, "memory_kb": 38128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s773321650", "group_id": "codeNet:p02615", "input_text": "fun main() {\n val n = readInt()\n val a = readLongs().sortedDescending()\n\n if (n == 2) println(a[0])\n else if (n == 3) println(a[0] + a[1])\n else if (n == 4) println(a[0] + 2 * a[1])\n else println(a[0] + 2 * a[1] + a.drop(2).take(n - 4).sum())\n}\n\nprivate fun readInt() = readLine()!!.toInt()\nprivate fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\nprivate fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1600401505, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02615/input.txt", "sample_output_relpath": "derived/input_output/data/p02615/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02615/Kotlin/s773321650.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s773321650", "user_id": "u178770699"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main() {\n val n = readInt()\n val a = readLongs().sortedDescending()\n\n if (n == 2) println(a[0])\n else if (n == 3) println(a[0] + a[1])\n else if (n == 4) println(a[0] + 2 * a[1])\n else println(a[0] + 2 * a[1] + a.drop(2).take(n - 4).sum())\n}\n\nprivate fun readInt() = readLine()!!.toInt()\nprivate fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\nprivate fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "sample_input": "4\n2 2 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02615", "source_text": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 629, "memory_kb": 75156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s182957972", "group_id": "codeNet:p02616", "input_text": "import kotlin.math.abs\n\nfun main() = Thread(null, ::abc173e, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc173e() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n if (k == n) return println(aList.fold(Mint(1), Mint::times))\n\n val (positives, negatives) = aList\n .sortedByDescending { abs(it) }.partition { it > 0 }.toList().map { ArrayDeque(it) }\n\n var answer = Mint(1)\n\n if (k % 2 != 0) {\n if (positives.isEmpty()) return println(negatives.takeLast(k).fold(Mint(1), Mint::times))\n else answer *= positives.removeFirst()\n }\n\n repeat(k / 2) {\n when {\n positives.size >= 2 && negatives.size >= 2 -> {\n val pos = positives.take(2).reduce(Long::times)\n val neg = negatives.take(2).reduce(Long::times)\n if (pos > neg) {\n answer *= pos\n repeat(2) { positives.removeFirst() }\n } else {\n answer *= neg\n repeat(2) { negatives.removeFirst() }\n }\n }\n positives.size >= 2 -> answer *= positives.removeFirst() * positives.removeFirst()\n negatives.size >= 2 -> answer *= negatives.removeFirst() * negatives.removeFirst()\n else -> error(\"なんで?\")\n }\n }\n\n println(answer)\n}\n\nprivate const val MOD = 1_000_000_007L\n\n@Suppress(\"unused\")\nprivate class Mint(value: Long = 0L) {\n constructor(other: Mint) : this(other.value)\n\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * Mint(other).value)\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = this.times(modPow(other, MOD - 2))\n operator fun div(other: Mint) = this.div(other.value)\n fun mod(mod: Long) = Mint(this.value % mod)\n fun modPow(other: Long) = Mint(modPow(this.value, other))\n fun toLong() = this.value\n override fun toString() = this.value.toString()\n override fun hashCode() = value.hashCode()\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n other as Mint\n return value == other.value\n }\n\n companion object {\n private fun modPow(n: Long, p: Long): Long {\n var x = n % MOD\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % MOD\n y = y shr 1\n x = (x * x) % MOD\n }\n return result\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1594001031, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/Kotlin/s182957972.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182957972", "user_id": "u139478771"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import kotlin.math.abs\n\nfun main() = Thread(null, ::abc173e, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc173e() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toLong() }\n\n if (k == n) return println(aList.fold(Mint(1), Mint::times))\n\n val (positives, negatives) = aList\n .sortedByDescending { abs(it) }.partition { it > 0 }.toList().map { ArrayDeque(it) }\n\n var answer = Mint(1)\n\n if (k % 2 != 0) {\n if (positives.isEmpty()) return println(negatives.takeLast(k).fold(Mint(1), Mint::times))\n else answer *= positives.removeFirst()\n }\n\n repeat(k / 2) {\n when {\n positives.size >= 2 && negatives.size >= 2 -> {\n val pos = positives.take(2).reduce(Long::times)\n val neg = negatives.take(2).reduce(Long::times)\n if (pos > neg) {\n answer *= pos\n repeat(2) { positives.removeFirst() }\n } else {\n answer *= neg\n repeat(2) { negatives.removeFirst() }\n }\n }\n positives.size >= 2 -> answer *= positives.removeFirst() * positives.removeFirst()\n negatives.size >= 2 -> answer *= negatives.removeFirst() * negatives.removeFirst()\n else -> error(\"なんで?\")\n }\n }\n\n println(answer)\n}\n\nprivate const val MOD = 1_000_000_007L\n\n@Suppress(\"unused\")\nprivate class Mint(value: Long = 0L) {\n constructor(other: Mint) : this(other.value)\n\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * Mint(other).value)\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = this.times(modPow(other, MOD - 2))\n operator fun div(other: Mint) = this.div(other.value)\n fun mod(mod: Long) = Mint(this.value % mod)\n fun modPow(other: Long) = Mint(modPow(this.value, other))\n fun toLong() = this.value\n override fun toString() = this.value.toString()\n override fun hashCode() = value.hashCode()\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n other as Mint\n return value == other.value\n }\n\n companion object {\n private fun modPow(n: Long, p: Long): Long {\n var x = n % MOD\n var y = p\n var result = 1L\n while (y > 0) {\n if (y % 2 == 1L) result = (result * x) % MOD\n y = y shr 1\n x = (x * x) % MOD\n }\n return result\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3168, "cpu_time_ms": 732, "memory_kb": 78596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s679452873", "group_id": "codeNet:p02617", "input_text": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval n = f.readLine().toInt()\n\n\tval adj = Array(n+1){mutableListOf()}\n\tfor(k in 2..n){\n\t\tval (a,b) = f.readLine().split(\" \").map{it.toInt()}\n\t\tadj[a].add(b)\n\t\tadj[b].add(a)\n\t}\n\n\tfor(k in 1..n) adj[k].sort()\n\n\tval a = LongArray(n+1){0L}\n\t//calc a[1]\n\n\ta[1] = 1L\n\tvar prev = 1L\n\tfor(k in 2..n){\n\t\tvar i = 0L\n\t\tfor(nei in adj[k]){\n\t\t\tif(nei < k) i++\n\t\t\telse break\n\t\t}\n\n\t\tprev = prev-(i-1)\n\t\ta[1] += prev\n\t}\n\n\tfor(k in 1 until n){\n\t\tval neis = mutableListOf()\n\n\t\tfor(nei in adj[k]){\n\t\t\tif(nei > k){\n\t\t\t\t//(\"nei $k $nei\")\n\t\t\t\tneis.add(nei)\n\t\t\t}\n\t\t}\n\n\t\tif(neis.size == 0){\n\t\t\ta[k+1] = a[k] - (n-k+1)\n\t\t} else {\n\t\t\t//println(\"neis[0] = ${neis[0]}\")\n\t\t\ta[k+1] = a[k] - (neis[0]-k)\n\t\t\tfor(j in 1 until neis.size-1){\n\t\t\t\ta[k+1] = a[k+1] + (n-neis[j]+1).toLong()\n\t\t\t}\n\t\t}\n\t}\n\n\tvar answer = 0L\n\tfor(k in 1..n){\n\t\t//println(a[k])\n\t\tanswer += a[k]\n\t}\n\tprintln(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1593981608, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02617.html", "problem_id": "p02617", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02617/input.txt", "sample_output_relpath": "derived/input_output/data/p02617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02617/Kotlin/s679452873.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s679452873", "user_id": "u140923503"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport kotlin.math.*\n\nfun main(){\n\tval f = BufferedReader(InputStreamReader(System.`in`))\n\n\tval n = f.readLine().toInt()\n\n\tval adj = Array(n+1){mutableListOf()}\n\tfor(k in 2..n){\n\t\tval (a,b) = f.readLine().split(\" \").map{it.toInt()}\n\t\tadj[a].add(b)\n\t\tadj[b].add(a)\n\t}\n\n\tfor(k in 1..n) adj[k].sort()\n\n\tval a = LongArray(n+1){0L}\n\t//calc a[1]\n\n\ta[1] = 1L\n\tvar prev = 1L\n\tfor(k in 2..n){\n\t\tvar i = 0L\n\t\tfor(nei in adj[k]){\n\t\t\tif(nei < k) i++\n\t\t\telse break\n\t\t}\n\n\t\tprev = prev-(i-1)\n\t\ta[1] += prev\n\t}\n\n\tfor(k in 1 until n){\n\t\tval neis = mutableListOf()\n\n\t\tfor(nei in adj[k]){\n\t\t\tif(nei > k){\n\t\t\t\t//(\"nei $k $nei\")\n\t\t\t\tneis.add(nei)\n\t\t\t}\n\t\t}\n\n\t\tif(neis.size == 0){\n\t\t\ta[k+1] = a[k] - (n-k+1)\n\t\t} else {\n\t\t\t//println(\"neis[0] = ${neis[0]}\")\n\t\t\ta[k+1] = a[k] - (neis[0]-k)\n\t\t\tfor(j in 1 until neis.size-1){\n\t\t\t\ta[k+1] = a[k+1] + (n-neis[j]+1).toLong()\n\t\t\t}\n\t\t}\n\t}\n\n\tvar answer = 0L\n\tfor(k in 1..n){\n\t\t//println(a[k])\n\t\tanswer += a[k]\n\t}\n\tprintln(answer)\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "sample_input": "3\n1 3\n2 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02617", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 993, "cpu_time_ms": 867, "memory_kb": 89844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s733828335", "group_id": "codeNet:p02619", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val d = readInteger()\n val cList = readLongList()\n val sPerDay = Array(d) { readLongList() }\n val tArray = Array(d) { readInteger() }\n\n calcScore(d, cList, sPerDay, tArray)\n}\n\nfun calcScore(d: Int, cList: List, sPerDay: Array>, tArray: Array): Long {\n var score = 0L\n val last = IntArray(26)\n for (i in 0 until d) {\n val contestNo = tArray[i] - 1\n score += sPerDay[i][contestNo]\n\n last[contestNo] = i + 1\n\n for (j in 0 until 26) score -= cList[j] * ((i + 1) - last[j])\n\n out.println(score)\n }\n\n return score\n}\n\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1597518714, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02619.html", "problem_id": "p02619", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02619/input.txt", "sample_output_relpath": "derived/input_output/data/p02619/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02619/Kotlin/s733828335.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s733828335", "user_id": "u784448849"}, "prompt_components": {"gold_output": "18398\n35037\n51140\n65837\n79325\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val d = readInteger()\n val cList = readLongList()\n val sPerDay = Array(d) { readLongList() }\n val tArray = Array(d) { readInteger() }\n\n calcScore(d, cList, sPerDay, tArray)\n}\n\nfun calcScore(d: Int, cList: List, sPerDay: Array>, tArray: Array): Long {\n var score = 0L\n val last = IntArray(26)\n for (i in 0 until d) {\n val contestNo = tArray[i] - 1\n score += sPerDay[i][contestNo]\n\n last[contestNo] = i + 1\n\n for (j in 0 until 26) score -= cList[j] * ((i + 1) - last[j])\n\n out.println(score)\n }\n\n return score\n}\n\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "(Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.)\n\nBeginner's Guide\n\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement\n\nYou will be given a contest schedule for D days.\nFor each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d, t_d is an integer satisfying 1\\leq t_d \\leq 26, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput\n\nLet v_d be the satisfaction at the end of day d.\nPrint D integers v_d to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_D\n\nSample Input 1\n\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1\n\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step\n\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,\\ldots,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\n\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "sample_input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n"}, "reference_outputs": ["18398\n35037\n51140\n65837\n79325\n"], "source_document_id": "p02619", "source_text": "(Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.)\n\nBeginner's Guide\n\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement\n\nYou will be given a contest schedule for D days.\nFor each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d, t_d is an integer satisfying 1\\leq t_d \\leq 26, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput\n\nLet v_d be the satisfaction at the end of day d.\nPrint D integers v_d to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_D\n\nSample Input 1\n\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1\n\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step\n\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,\\ldots,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\n\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1335, "cpu_time_ms": 147, "memory_kb": 38304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s492267658", "group_id": "codeNet:p02620", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\nimport kotlin.math.tan\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val d = readInteger()\n val cList = readLongList()\n val sPerDay = Array(d) { readLongList() }\n val tArray = Array(d) { readInteger() }\n val m = readInteger()\n repeat(m) {\n val (toD, toQ) = readIntegerList()\n tArray[toD - 1] = toQ\n val score = calcScore(d, cList, sPerDay, tArray)\n out.println(score)\n }\n\n// for (i in 0 until d) {\n// var maxT = 1\n// var maxScore = Long.MIN_VALUE\n// for (j in 0 until 26) {\n// tArray[i] = j + 1\n// val tmpScore = calcScore(i + 1, cList, sPerDay, tArray)\n//\n// if (tmpScore > maxScore) {\n// maxT = j + 1\n// maxScore = tmpScore\n// }\n// }\n//\n//// out.println(\"max score: $maxScore\")\n// tArray[i] = maxT\n// }\n//\n// for (t in tArray) {\n// out.println(t)\n// }\n}\n\nfun calcScore(d: Int, cList: List, sPerDay: Array>, tArray: Array): Long {\n var score = 0L\n val last = IntArray(26)\n for (i in 0 until d) {\n val contestNo = tArray[i] - 1\n score += sPerDay[i][contestNo]\n\n last[contestNo] = i + 1\n\n for (j in 0 until 26) score -= cList[j] * ((i + 1) - last[j])\n }\n\n return score\n}\n\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1597520194, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02620.html", "problem_id": "p02620", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02620/input.txt", "sample_output_relpath": "derived/input_output/data/p02620/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02620/Kotlin/s492267658.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492267658", "user_id": "u784448849"}, "prompt_components": {"gold_output": "72882\n56634\n38425\n27930\n42884\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.sqrt\nimport kotlin.math.tan\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val d = readInteger()\n val cList = readLongList()\n val sPerDay = Array(d) { readLongList() }\n val tArray = Array(d) { readInteger() }\n val m = readInteger()\n repeat(m) {\n val (toD, toQ) = readIntegerList()\n tArray[toD - 1] = toQ\n val score = calcScore(d, cList, sPerDay, tArray)\n out.println(score)\n }\n\n// for (i in 0 until d) {\n// var maxT = 1\n// var maxScore = Long.MIN_VALUE\n// for (j in 0 until 26) {\n// tArray[i] = j + 1\n// val tmpScore = calcScore(i + 1, cList, sPerDay, tArray)\n//\n// if (tmpScore > maxScore) {\n// maxT = j + 1\n// maxScore = tmpScore\n// }\n// }\n//\n//// out.println(\"max score: $maxScore\")\n// tArray[i] = maxT\n// }\n//\n// for (t in tArray) {\n// out.println(t)\n// }\n}\n\nfun calcScore(d: Int, cList: List, sPerDay: Array>, tArray: Array): Long {\n var score = 0L\n val last = IntArray(26)\n for (i in 0 until d) {\n val contestNo = tArray[i] - 1\n score += sPerDay[i][contestNo]\n\n last[contestNo] = i + 1\n\n for (j in 0 until 26) score -= cList[j] * ((i + 1) - last[j])\n }\n\n return score\n}\n\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "(Please read problem A first. The maximum score you can get by solving this problem C is 1, which will have almost no effect on your ranking.)\n\nBeginner's Guide\n\n\"Local search\" is a powerful method for finding a high-quality solution.\nIn this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution.\nIf the solution gets better, update it, and if it gets worse, restore it.\nBy repeating this process, the quality of the solution is gradually improved over time.\nThe pseudo-code is as follows.\n\nsolution = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\nslightly modify the solution (randomly)\nif the solution gets worse:\nrestore the solution\n\nFor example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q.\nThe pseudo-code is as follows.\n\nt[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\npick d and q at random\nold = t[d] # Remember the original value so that we can restore it later\nt[d] = q\nif the solution gets worse:\nt[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n\nIf the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small.\n\nIn order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification.\n\nIn this problem C, we focus on the second point.\nThe score after the modification can, of course, be obtained by calculating the score from scratch.\nHowever, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification.\nFrom another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation.\nIn such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search.\nLet's implement fast incremental score computation.\nIt's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC!\n\nIn this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug.\nFor early detection of bugs, it is a good idea to unit test functions you implemented complicated routines.\nFor example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.\n\nProblem Statement\n\nYou will be given a contest schedule for D days and M queries of schedule modification.\nIn the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule.\nNote that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\nM\nd_1 q_1\nd_2 q_2\n\\vdots\nd_M q_M\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d=1,\\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\\ldots,26}.\n\nThe number of queries M is an integer satisfying 1\\leq M\\leq 10^5.\n\nFor each i=1,\\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\\ldots,D}.\n\nFor each i=1,\\ldots,26, q_i is an integer satisfying 1\\leq q_i\\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.\n\nOutput\n\nLet v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query.\nPrint M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_M\n\nSample Input 1\n\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n\nSample Output 1\n\n72882\n56634\n38425\n27930\n42884\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step\n\nLet's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented!\nFor this problem, the current modification \"pick the date d and contest type q at random and change the type of contest to be held on day d to q\" is actually not so good. By considering why it is not good, let's improve the modification operation.\nOne of the most powerful and widely used variant of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves.\nFor more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "sample_input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n"}, "reference_outputs": ["72882\n56634\n38425\n27930\n42884\n"], "source_document_id": "p02620", "source_text": "(Please read problem A first. The maximum score you can get by solving this problem C is 1, which will have almost no effect on your ranking.)\n\nBeginner's Guide\n\n\"Local search\" is a powerful method for finding a high-quality solution.\nIn this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution.\nIf the solution gets better, update it, and if it gets worse, restore it.\nBy repeating this process, the quality of the solution is gradually improved over time.\nThe pseudo-code is as follows.\n\nsolution = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\nslightly modify the solution (randomly)\nif the solution gets worse:\nrestore the solution\n\nFor example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q.\nThe pseudo-code is as follows.\n\nt[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\npick d and q at random\nold = t[d] # Remember the original value so that we can restore it later\nt[d] = q\nif the solution gets worse:\nt[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n\nIf the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small.\n\nIn order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification.\n\nIn this problem C, we focus on the second point.\nThe score after the modification can, of course, be obtained by calculating the score from scratch.\nHowever, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification.\nFrom another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation.\nIn such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search.\nLet's implement fast incremental score computation.\nIt's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC!\n\nIn this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug.\nFor early detection of bugs, it is a good idea to unit test functions you implemented complicated routines.\nFor example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.\n\nProblem Statement\n\nYou will be given a contest schedule for D days and M queries of schedule modification.\nIn the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule.\nNote that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\nM\nd_1 q_1\nd_2 q_2\n\\vdots\nd_M q_M\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d=1,\\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\\ldots,26}.\n\nThe number of queries M is an integer satisfying 1\\leq M\\leq 10^5.\n\nFor each i=1,\\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\\ldots,D}.\n\nFor each i=1,\\ldots,26, q_i is an integer satisfying 1\\leq q_i\\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.\n\nOutput\n\nLet v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query.\nPrint M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_M\n\nSample Input 1\n\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n\nSample Output 1\n\n72882\n56634\n38425\n27930\n42884\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step\n\nLet's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented!\nFor this problem, the current modification \"pick the date d and contest type q at random and change the type of contest to be held on day d to q\" is actually not so good. By considering why it is not good, let's improve the modification operation.\nOne of the most powerful and widely used variant of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves.\nFor more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2011, "cpu_time_ms": 1675, "memory_kb": 57928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s585182659", "group_id": "codeNet:p02621", "input_text": "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 s = readInt()\n println(\"${s + s*s + s*s*s}\")\n}", "language": "Kotlin", "metadata": {"date": 1599186543, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02621/input.txt", "sample_output_relpath": "derived/input_output/data/p02621/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02621/Kotlin/s585182659.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s585182659", "user_id": "u535010493"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "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 s = readInt()\n println(\"${s + s*s + s*s*s}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "sample_input": "2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02621", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 313, "cpu_time_ms": 97, "memory_kb": 34432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s553894735", "group_id": "codeNet:p02621", "input_text": "fun main (args:Array){\n val inputNum = readLine()!!.toDouble()\n val numPow2 = Math.pow(inputNum,2.0)\n val numPow3 = Math.pow(inputNum,3.0)\n val outputNum = inputNum + numPow2 + numPow3\n print(outputNum.toInt())\n}", "language": "Kotlin", "metadata": {"date": 1593619090, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02621/input.txt", "sample_output_relpath": "derived/input_output/data/p02621/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02621/Kotlin/s553894735.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s553894735", "user_id": "u800824593"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main (args:Array){\n val inputNum = readLine()!!.toDouble()\n val numPow2 = Math.pow(inputNum,2.0)\n val numPow3 = Math.pow(inputNum,3.0)\n val outputNum = inputNum + numPow2 + numPow3\n print(outputNum.toInt())\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "sample_input": "2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02621", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 97, "memory_kb": 34648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s201392854", "group_id": "codeNet:p02621", "input_text": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n val a = readInt()\n println(a + a * a + a * a * a)\n}", "language": "Kotlin", "metadata": {"date": 1593322750, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02621/input.txt", "sample_output_relpath": "derived/input_output/data/p02621/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02621/Kotlin/s201392854.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s201392854", "user_id": "u657541767"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n val a = readInt()\n println(a + a * a + a * a * a)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "sample_input": "2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02621", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 407, "cpu_time_ms": 101, "memory_kb": 34000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s145190070", "group_id": "codeNet:p02622", "input_text": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.HashSet\nimport kotlin.math.*\nfun main(){\n var fs = CodeForces.FastReader()\n var s = fs.next()\n var t = fs.next()\n var ans = 0\n for (i in 0 until s.length) {\n if(s[i] != t[i]) ans++\n }\n println(ans)\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n 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", "language": "Kotlin", "metadata": {"date": 1599178128, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Kotlin/s145190070.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s145190070", "user_id": "u843609965"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.collections.HashSet\nimport kotlin.math.*\nfun main(){\n var fs = CodeForces.FastReader()\n var s = fs.next()\n var t = fs.next()\n var ans = 0\n for (i in 0 until s.length) {\n if(s[i] != t[i]) ans++\n }\n println(ans)\n}\n\nclass CodeForces {\n internal class FastReader {\n private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))\n private var st: StringTokenizer? = null\n\n operator fun next(): String {\n while (st == null || !st!!.hasMoreElements()) {\n try {\n st = StringTokenizer(br.readLine())\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n }\n return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return Integer.parseInt(next())\n }\n\n fun nextLong(): Long {\n return java.lang.Long.parseLong(next())\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun readIntArray(n: Int): IntArray {\n val a = IntArray(n)\n for (i in 0 until n) a[i] = nextInt()\n return a\n }\n 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", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1905, "cpu_time_ms": 184, "memory_kb": 38640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s413139227", "group_id": "codeNet:p02622", "input_text": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n val count = s.zip(t).count { (a, b) ->\n a != b\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1593307039, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Kotlin/s413139227.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s413139227", "user_id": "u267722582"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n val count = s.zip(t).count { (a, b) ->\n a != b\n }\n println(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 296, "memory_kb": 47736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s214451447", "group_id": "codeNet:p02622", "input_text": "fun main(){\n val s = readLine()!!.split(\" \")[0].toCharArray()\n val t = readLine()!!.split(\" \")[0].toCharArray()\n var ans = 0\n for (i in 0 until s.size){\n if (s[i] != t[i]){\n ans++\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1593306284, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Kotlin/s214451447.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214451447", "user_id": "u385678999"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(){\n val s = readLine()!!.split(\" \")[0].toCharArray()\n val t = readLine()!!.split(\" \")[0].toCharArray()\n var ans = 0\n for (i in 0 until s.size){\n if (s[i] != t[i]){\n ans++\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 245, "cpu_time_ms": 251, "memory_kb": 43480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s807887599", "group_id": "codeNet:p02622", "input_text": "\nfun main(args: Array) {\n val a = readLine()!!\n val b = readLine()!!\n println(a.zip(b).count { it.first != it.second })\n}", "language": "Kotlin", "metadata": {"date": 1593306146, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Kotlin/s807887599.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s807887599", "user_id": "u895858420"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nfun main(args: Array) {\n val a = readLine()!!\n val b = readLine()!!\n println(a.zip(b).count { it.first != it.second })\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 299, "memory_kb": 47668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s279945250", "group_id": "codeNet:p02626", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toLong() }\n val xor = a.drop(2).fold(0L, Long::xor)\n fun solve(a: Long, b: Long, c: Long): Long {\n if (a xor b == c) return 0L\n val bit = java.lang.Long.highestOneBit(c)\n if (bit == 0L) {\n return if (a <= b || (a + b) % 2 != 0L) -1 else {\n a - (a + b) / 2\n }\n }\n if (a >= bit * 2 || b >= bit * 2) return -1\n if (((a xor b) and bit) == bit) return solve(a and (bit - 1), b and (bit - 1), c xor bit)\n if ((a and bit == bit) && (b and bit == bit)) {\n val t = a - bit + 1\n check(a - t < bit) { \"$a $t $b $bit $c\"}\n if ((b + t) >= bit * 2) return -1\n return t + solve(a - t, (b + t) and (bit - 1), c xor bit)\n }\n val need = bit - b\n if (a < need) return -1\n return need + solve(a - need, (b + need) and (bit - 1), c xor bit)\n }\n\n val res = solve(a[0], a[1], xor)\n println(if (res < a[0]) res else -1)\n}", "language": "Kotlin", "metadata": {"date": 1593311839, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02626.html", "problem_id": "p02626", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02626/input.txt", "sample_output_relpath": "derived/input_output/data/p02626/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02626/Kotlin/s279945250.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s279945250", "user_id": "u496795059"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toLong() }\n val xor = a.drop(2).fold(0L, Long::xor)\n fun solve(a: Long, b: Long, c: Long): Long {\n if (a xor b == c) return 0L\n val bit = java.lang.Long.highestOneBit(c)\n if (bit == 0L) {\n return if (a <= b || (a + b) % 2 != 0L) -1 else {\n a - (a + b) / 2\n }\n }\n if (a >= bit * 2 || b >= bit * 2) return -1\n if (((a xor b) and bit) == bit) return solve(a and (bit - 1), b and (bit - 1), c xor bit)\n if ((a and bit == bit) && (b and bit == bit)) {\n val t = a - bit + 1\n check(a - t < bit) { \"$a $t $b $bit $c\"}\n if ((b + t) >= bit * 2) return -1\n return t + solve(a - t, (b + t) and (bit - 1), c xor bit)\n }\n val need = bit - b\n if (a < need) return -1\n return need + solve(a - need, (b + need) and (bit - 1), c xor bit)\n }\n\n val res = solve(a[0], a[1], xor)\n println(if (res < a[0]) res else -1)\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N piles of stones. The i-th pile has A_i stones.\n\nAoki and Takahashi are about to use them to play the following game:\n\nStarting with Aoki, the two players alternately do the following operation:\n\nOperation: Choose one pile of stones, and remove one or more stones from it.\n\nWhen a player is unable to do the operation, he loses, and the other player wins.\n\nWhen the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.\n\nIn such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.\n\nIf this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print -1 instead.\n\nConstraints\n\n2 \\leq N \\leq 300\n\n1 \\leq A_i \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum number of stones to move to guarantee Takahashi's win; otherwise, print -1 instead.\n\nSample Input 1\n\n2\n5 3\n\nSample Output 1\n\n1\n\nWithout moving stones, if Aoki first removes 2 stones from the 1-st pile, Takahashi cannot win in any way.\n\nIf Takahashi moves 1 stone from the 1-st pile to the 2-nd before the game begins so that both piles have 4 stones, Takahashi can always win by properly choosing his actions.\n\nSample Input 2\n\n2\n3 5\n\nSample Output 2\n\n-1\n\nIt is not allowed to move stones from the 2-nd pile to the 1-st.\n\nSample Input 3\n\n3\n1 1 2\n\nSample Output 3\n\n-1\n\nIt is not allowed to move all stones from the 1-st pile.\n\nSample Input 4\n\n8\n10 9 8 7 6 5 4 3\n\nSample Output 4\n\n3\n\nSample Input 5\n\n3\n4294967297 8589934593 12884901890\n\nSample Output 5\n\n1\n\nWatch out for overflows.", "sample_input": "2\n5 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02626", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N piles of stones. The i-th pile has A_i stones.\n\nAoki and Takahashi are about to use them to play the following game:\n\nStarting with Aoki, the two players alternately do the following operation:\n\nOperation: Choose one pile of stones, and remove one or more stones from it.\n\nWhen a player is unable to do the operation, he loses, and the other player wins.\n\nWhen the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.\n\nIn such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.\n\nIf this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print -1 instead.\n\nConstraints\n\n2 \\leq N \\leq 300\n\n1 \\leq A_i \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum number of stones to move to guarantee Takahashi's win; otherwise, print -1 instead.\n\nSample Input 1\n\n2\n5 3\n\nSample Output 1\n\n1\n\nWithout moving stones, if Aoki first removes 2 stones from the 1-st pile, Takahashi cannot win in any way.\n\nIf Takahashi moves 1 stone from the 1-st pile to the 2-nd before the game begins so that both piles have 4 stones, Takahashi can always win by properly choosing his actions.\n\nSample Input 2\n\n2\n3 5\n\nSample Output 2\n\n-1\n\nIt is not allowed to move stones from the 2-nd pile to the 1-st.\n\nSample Input 3\n\n3\n1 1 2\n\nSample Output 3\n\n-1\n\nIt is not allowed to move all stones from the 1-st pile.\n\nSample Input 4\n\n8\n10 9 8 7 6 5 4 3\n\nSample Output 4\n\n3\n\nSample Input 5\n\n3\n4294967297 8589934593 12884901890\n\nSample Output 5\n\n1\n\nWatch out for overflows.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 959, "cpu_time_ms": 137, "memory_kb": 37932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s575803106", "group_id": "codeNet:p02627", "input_text": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n val s = readString()\n\n if (s[0].isUpperCase()) {\n println('A')\n } else {\n println('a')\n }\n}", "language": "Kotlin", "metadata": {"date": 1592788434, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02627/input.txt", "sample_output_relpath": "derived/input_output/data/p02627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02627/Kotlin/s575803106.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s575803106", "user_id": "u657541767"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n val s = readString()\n\n if (s[0].isUpperCase()) {\n println('A')\n } else {\n println('a')\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 467, "cpu_time_ms": 111, "memory_kb": 34472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s337402296", "group_id": "codeNet:p02627", "input_text": "fun main(args: Array) {\n val a = readLine()!!.first()\n if (a in 'A'..'Z') println(\"A\")\n else println(\"a\")\n}", "language": "Kotlin", "metadata": {"date": 1592787671, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02627/input.txt", "sample_output_relpath": "derived/input_output/data/p02627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02627/Kotlin/s337402296.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s337402296", "user_id": "u895858420"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "fun main(args: Array) {\n val a = readLine()!!.first()\n if (a in 'A'..'Z') println(\"A\")\n else println(\"a\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 115, "memory_kb": 35680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s475345526", "group_id": "codeNet:p02628", "input_text": "fun main() {\n val k = readLine()!!.split(' ')[1].toInt()\n var mink = 0\n var sum = 0\n val p = readLine()!!.split(' ').map { it.toInt() }\n for(i in p.indices) {\n if(i < k) {\n sum += p[i]\n if(mink < p[i]) mink = p[i]\n }\n else if(mink > p[i]){\n sum -= mink\n mink = p[i]\n sum += mink\n }\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1600393658, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/Kotlin/s475345526.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s475345526", "user_id": "u262303334"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "fun main() {\n val k = readLine()!!.split(' ')[1].toInt()\n var mink = 0\n var sum = 0\n val p = readLine()!!.split(' ').map { it.toInt() }\n for(i in p.indices) {\n if(i < k) {\n sum += p[i]\n if(mink < p[i]) mink = p[i]\n }\n else if(mink > p[i]){\n sum -= mink\n mink = p[i]\n sum += mink\n }\n }\n println(sum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 131, "memory_kb": 38148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s979675511", "group_id": "codeNet:p02628", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val fruits = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n\n fun countFruit(fruits: List, limit: Int, amount: Int = 0): Int {\n return if (limit < 1 || fruits.isEmpty()) amount else countFruit(fruits.takeLast(fruits.size - 1), limit - 1, amount + fruits[0])\n }\n\n println(countFruit(fruits, K))\n}\n", "language": "Kotlin", "metadata": {"date": 1600009548, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/Kotlin/s979675511.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s979675511", "user_id": "u496449946"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n val fruits = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n\n fun countFruit(fruits: List, limit: Int, amount: Int = 0): Int {\n return if (limit < 1 || fruits.isEmpty()) amount else countFruit(fruits.takeLast(fruits.size - 1), limit - 1, amount + fruits[0])\n }\n\n println(countFruit(fruits, K))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 418, "cpu_time_ms": 163, "memory_kb": 42836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s433793222", "group_id": "codeNet:p02628", "input_text": "fun main() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val a = readLine()!!.split(' ').map { it.toInt() }.sorted()\n println(a.subList(0, k).sum())\n}", "language": "Kotlin", "metadata": {"date": 1593048158, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/Kotlin/s433793222.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433793222", "user_id": "u323881321"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "fun main() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val a = readLine()!!.split(' ').map { it.toInt() }.sorted()\n println(a.subList(0, k).sum())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 167, "cpu_time_ms": 156, "memory_kb": 40572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s213961736", "group_id": "codeNet:p02629", "input_text": "//\n\nfun main() {\n abc171c()\n}\n\nfun abc171c() {\n val n = readLine()!!.toLong()\n var tmp = n\n var name = \"\"\n val nameTable = ('a'..'z').toList()\n while (tmp > 0L) {\n tmp -= 1\n val r = tmp % 26\n name = \"${nameTable[r.toInt()]}$name\"\n tmp /= 26\n }\n println(name)\n}\n", "language": "Kotlin", "metadata": {"date": 1596846427, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Kotlin/s213961736.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213961736", "user_id": "u628907033"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "//\n\nfun main() {\n abc171c()\n}\n\nfun abc171c() {\n val n = readLine()!!.toLong()\n var tmp = n\n var name = \"\"\n val nameTable = ('a'..'z').toList()\n while (tmp > 0L) {\n tmp -= 1\n val r = tmp % 26\n name = \"${nameTable[r.toInt()]}$name\"\n tmp /= 26\n }\n println(name)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 313, "cpu_time_ms": 111, "memory_kb": 35548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192887369", "group_id": "codeNet:p02629", "input_text": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n var n = readLong()\n var res = \"\"\n while (n > 0) {\n n -= 1\n res += ('a'.toByte() + n % 26).toChar()\n// n = floor(n.toDouble()/26).toLong()\n n /= 26\n }\n println(res.reversed())\n}\n", "language": "Kotlin", "metadata": {"date": 1592795628, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Kotlin/s192887369.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192887369", "user_id": "u657541767"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n var n = readLong()\n var res = \"\"\n while (n > 0) {\n n -= 1\n res += ('a'.toByte() + n % 26).toChar()\n// n = floor(n.toDouble()/26).toLong()\n n /= 26\n }\n println(res.reversed())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 574, "cpu_time_ms": 120, "memory_kb": 35744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s970282418", "group_id": "codeNet:p02629", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n var answer = \"\"\n val alphabets = arrayOf(\"z\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\" , \"j\", \"k\", \"l\", \"m\",\"n\", \"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\")\n if (n == Math.pow(26.0, 1.0).toLong()) return println(\"z\")\n if (n == Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zz\")\n if (n == Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzz\")\n if (n == Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzz\")\n if (n == Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzz\")\n if (n == Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzz\")\n if (n == Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzz\")\n if (n == Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzz\")\n if (n == Math.pow(26.0, 9.0).toLong() + Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzzz\")\n if (n == Math.pow(26.0, 10.0).toLong() + Math.pow(26.0, 9.0).toLong() + Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzzzz\")\n if (n == Math.pow(26.0, 11.0).toLong() + Math.pow(26.0, 10.0).toLong() + Math.pow(26.0, 9.0).toLong() + Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzzzzz\")\n for (i in 10 downTo 0) {\n if ((n/ Math.pow(26.0,i.toDouble()) % 26).toInt() > 0) {\n answer += alphabets[(n / Math.pow(26.0,i.toDouble()) % 26).toInt()]\n }\n }\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1592791555, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Kotlin/s970282418.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s970282418", "user_id": "u172820018"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n var answer = \"\"\n val alphabets = arrayOf(\"z\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\" , \"j\", \"k\", \"l\", \"m\",\"n\", \"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\")\n if (n == Math.pow(26.0, 1.0).toLong()) return println(\"z\")\n if (n == Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zz\")\n if (n == Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzz\")\n if (n == Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzz\")\n if (n == Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzz\")\n if (n == Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzz\")\n if (n == Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzz\")\n if (n == Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzz\")\n if (n == Math.pow(26.0, 9.0).toLong() + Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzzz\")\n if (n == Math.pow(26.0, 10.0).toLong() + Math.pow(26.0, 9.0).toLong() + Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzzzz\")\n if (n == Math.pow(26.0, 11.0).toLong() + Math.pow(26.0, 10.0).toLong() + Math.pow(26.0, 9.0).toLong() + Math.pow(26.0, 8.0).toLong() + Math.pow(26.0, 7.0).toLong() + Math.pow(26.0, 6.0).toLong() + Math.pow(26.0, 5.0).toLong() + Math.pow(26.0, 4.0).toLong() + Math.pow(26.0, 3.0).toLong() + Math.pow(26.0, 2.0).toLong() + Math.pow(26.0, 1.0).toLong()) return println(\"zzzzzzzzzzz\")\n for (i in 10 downTo 0) {\n if ((n/ Math.pow(26.0,i.toDouble()) % 26).toInt() > 0) {\n answer += alphabets[(n / Math.pow(26.0,i.toDouble()) % 26).toInt()]\n }\n }\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2908, "cpu_time_ms": 103, "memory_kb": 34528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s657033262", "group_id": "codeNet:p02629", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n var n = readLong()\n var ans = \"\"\n val charList = ('a' .. 'z').toList()\n while(n > 0) {\n var i = (n % 26L).toInt() - 1\n if(i == -1) {\n i = 25\n }\n ans = charList[i] + ans\n n /= 26L\n }\n println(ans)\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1592788933, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Kotlin/s657033262.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s657033262", "user_id": "u026686258"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n var n = readLong()\n var ans = \"\"\n val charList = ('a' .. 'z').toList()\n while(n > 0) {\n var i = (n % 26L).toInt() - 1\n if(i == -1) {\n i = 25\n }\n ans = charList[i] + ans\n n /= 26L\n }\n println(ans)\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6036, "cpu_time_ms": 120, "memory_kb": 35764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s280085720", "group_id": "codeNet:p02630", "input_text": "@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\nfun main() {\n _writer.solve(); _writer.flush()\n}\n\nfun PrintWriter.solve() {\n var n = readInt()\n var arr = LongArray(n){readLong()}\n\n var sum = arr.sum()\n\n var map = mutableMapOf()\n\n for (i in arr){\n map[i] = map.getOrDefault(i,0L) + 1\n }\n\n\n\n repeat(readInt()){\n var b = readLong()\n var c= readLong()\n\n if (b !in map)println(sum)\n else {\n var diff = (c-b)*map[b]!!\n sum+=diff\n println(sum)\n var v = map[b]!!\n map.remove(b)\n map[c] = map.getOrDefault(c,0) + v\n }\n\n\n }\n\n\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField\nval INPUT = System.`in`\n@JvmField\nval OUTPUT = System.out\n\n@JvmField\nval _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField\nvar _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\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\nval _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\nvar _random: Random? = null\nval random get() = _random ?: Random(0x591E215C121 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() {\n shuffle(); _sort()\n}\n\nfun IntArray.sortDescending() {\n shuffle(); _sortDescending()\n}\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() {\n shuffle(); _sort()\n}\n\nfun LongArray.sortDescending() {\n shuffle(); _sortDescending()\n}\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() {\n shuffle(); _sort()\n}\n\nfun DoubleArray.sortDescending() {\n shuffle(); _sortDescending()\n}\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() {\n _sort()\n}\n\ninline fun CharArray.sortDescending() {\n _sortDescending()\n}\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}", "language": "Kotlin", "metadata": {"date": 1593213787, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02630/input.txt", "sample_output_relpath": "derived/input_output/data/p02630/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02630/Kotlin/s280085720.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s280085720", "user_id": "u424241608"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "@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\nfun main() {\n _writer.solve(); _writer.flush()\n}\n\nfun PrintWriter.solve() {\n var n = readInt()\n var arr = LongArray(n){readLong()}\n\n var sum = arr.sum()\n\n var map = mutableMapOf()\n\n for (i in arr){\n map[i] = map.getOrDefault(i,0L) + 1\n }\n\n\n\n repeat(readInt()){\n var b = readLong()\n var c= readLong()\n\n if (b !in map)println(sum)\n else {\n var diff = (c-b)*map[b]!!\n sum+=diff\n println(sum)\n var v = map[b]!!\n map.remove(b)\n map[c] = map.getOrDefault(c,0) + v\n }\n\n\n }\n\n\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField\nval INPUT = System.`in`\n@JvmField\nval OUTPUT = System.out\n\n@JvmField\nval _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField\nvar _tokenizer: StringTokenizer = StringTokenizer(\"\")\nfun read(): String {\n while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return \"\", \" \")\n return _tokenizer.nextToken()\n}\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\nval _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\nvar _random: Random? = null\nval random get() = _random ?: Random(0x591E215C121 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() {\n shuffle(); _sort()\n}\n\nfun IntArray.sortDescending() {\n shuffle(); _sortDescending()\n}\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() {\n shuffle(); _sort()\n}\n\nfun LongArray.sortDescending() {\n shuffle(); _sortDescending()\n}\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() {\n shuffle(); _sort()\n}\n\nfun DoubleArray.sortDescending() {\n shuffle(); _sortDescending()\n}\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() {\n _sort()\n}\n\ninline fun CharArray.sortDescending() {\n _sortDescending()\n}\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}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "sample_input": "4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["11\n12\n16\n"], "source_document_id": "p02630", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3750, "cpu_time_ms": 498, "memory_kb": 65688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s240576091", "group_id": "codeNet:p02630", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val aList = readListOfInt()\n val q = readInt()\n val aMap = mutableMapOf()\n aList.forEach { a ->\n aMap[a] = (aMap[a]?: 0) + 1\n }\n var total = aMap.entries.fold(0L) { acc, x -> acc + x.key.toLong() * x.value.toLong() }\n for(i in 0 until q) {\n val (b, c) = readListOfInt()\n if(aMap.contains(b)) {\n val bNum = aMap[b]!!\n aMap[b] = 0\n aMap[c] = (aMap[c]?:0) + bNum\n total += (c-b).toLong() * bNum.toLong()\n }\n println(total)\n }\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1592790535, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02630/input.txt", "sample_output_relpath": "derived/input_output/data/p02630/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02630/Kotlin/s240576091.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240576091", "user_id": "u026686258"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val n = readInt()\n val aList = readListOfInt()\n val q = readInt()\n val aMap = mutableMapOf()\n aList.forEach { a ->\n aMap[a] = (aMap[a]?: 0) + 1\n }\n var total = aMap.entries.fold(0L) { acc, x -> acc + x.key.toLong() * x.value.toLong() }\n for(i in 0 until q) {\n val (b, c) = readListOfInt()\n if(aMap.contains(b)) {\n val bNum = aMap[b]!!\n aMap[b] = 0\n aMap[c] = (aMap[c]?:0) + bNum\n total += (c-b).toLong() * bNum.toLong()\n }\n println(total)\n }\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> Array.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().upperBound(element, fromIndex, toIndex)\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> Array.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int\n\t= this.toList().lowerBound(element, fromIndex, toIndex)\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element > this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfun Long.primeFactorize(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "sample_input": "4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["11\n12\n16\n"], "source_document_id": "p02630", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6333, "cpu_time_ms": 771, "memory_kb": 73772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s899857425", "group_id": "codeNet:p02631", "input_text": "fun main() {\n\tval n = readLine()!!.toInt()\n\tval a = readLine()!!.split(\" \").map {it.toInt()}\n\tval m = a.reduce {i,j-> i xor j}\n\tprintln(a.map {m xor it}.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1592800269, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Kotlin/s899857425.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899857425", "user_id": "u059234158"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "fun main() {\n\tval n = readLine()!!.toInt()\n\tval a = readLine()!!.split(\" \").map {it.toInt()}\n\tval m = a.reduce {i,j-> i xor j}\n\tprintln(a.map {m xor it}.joinToString(\" \"))\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 174, "cpu_time_ms": 567, "memory_kb": 78208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s115588899", "group_id": "codeNet:p02631", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }\n\n val allXor = aa.reduce { acc, i -> acc.xor(i) }\n val ans = mutableListOf()\n\n aa.forEach { a ->\n ans.add(a.xor(allXor))\n }\n\n println(ans.joinToString(separator = \" \"))\n}", "language": "Kotlin", "metadata": {"date": 1592795133, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Kotlin/s115588899.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115588899", "user_id": "u262403099"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }\n\n val allXor = aa.reduce { acc, i -> acc.xor(i) }\n val ans = mutableListOf()\n\n aa.forEach { a ->\n ans.add(a.xor(allXor))\n }\n\n println(ans.joinToString(separator = \" \"))\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 574, "memory_kb": 73640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285184215", "group_id": "codeNet:p02631", "input_text": "fun main() {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }\n\n var s = 0L\n A.forEach { a ->\n s = s.xor(a)\n }\n\n val B = LongArray(N)\n for(i in 0 until N){\n B[i] = s.xor(A[i])\n }\n println(B.joinToString(separator = \" \"))\n}", "language": "Kotlin", "metadata": {"date": 1592794892, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Kotlin/s285184215.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285184215", "user_id": "u531770859"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "fun main() {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }\n\n var s = 0L\n A.forEach { a ->\n s = s.xor(a)\n }\n\n val B = LongArray(N)\n for(i in 0 until N){\n B[i] = s.xor(A[i])\n }\n println(B.joinToString(separator = \" \"))\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 553, "memory_kb": 69648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s694409233", "group_id": "codeNet:p02631", "input_text": "fun main() {\n var n = 0\n nextInt()\n val values = nextIntList()\n values.forEach {\n n = n xor it\n }\n values.forEach {\n print(n xor it)\n if (it == values.lastIndex){\n println()\n } else {\n print(' ')\n }\n }\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\n", "language": "Kotlin", "metadata": {"date": 1592791783, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Kotlin/s694409233.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s694409233", "user_id": "u885556801"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "fun main() {\n var n = 0\n nextInt()\n val values = nextIntList()\n values.forEach {\n n = n xor it\n }\n values.forEach {\n print(n xor it)\n if (it == values.lastIndex){\n println()\n } else {\n print(' ')\n }\n }\n}\n\n// # Utils\n// ## Input\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map(String::toInt)\nfun nextLongList() = next().split(\" \").map(String::toLong)\nfun nextDoubleList() = next().split(\" \").map(String::toDouble)\n\n// ## Array\ninline fun sizedArray(size: Int, default: T) = Array(size) { default }\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 743, "cpu_time_ms": 1201, "memory_kb": 73468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s632775476", "group_id": "codeNet:p02632", "input_text": "import java.util.Scanner\n\nfun main() {\n\tval scn = Scanner(System.`in`)\n\tval k = scn.nextInt()\n\tval s = scn.next()\n\tval l = s.length\n\tval f = mutableListOf(ModInt(1))\n\tfor (i in 1..l+k){\n\t\tf.add(f.last()*i)\n\t}\n\tval bef = Array(k+1){ModInt.pow(25, it)*f[l-1+it]/(f[it]*f[l-1])}\n\tval arr = mutableListOf(ModInt(1))\n\tfor (c in 1..k){\n\t\tarr.add(arr.last()*26+bef[c])\n\t}\n\tprintln(arr.last())\n}\n\nclass ModInt {\n\tvar v: Long\n\t\tprivate set\n\tconstructor(v: Int){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v.toLong() % MOD\n\t\t\tv==Int.MIN_VALUE -> 852516373\n\t\t\telse -> MOD.toLong() - (-v%MOD)\n\t\t}\n\t}\n\tconstructor(v: Long){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v % MOD\n\t\t\tv==Long.MIN_VALUE -> 708828003\n\t\t\telse -> MOD - (-v%MOD)\n\t\t}\n\t}\n\n\toverride fun toString() = v.toString()\n\tfun toInt() = v.toInt()\n\tfun toLong() = v\n\toverride fun equals(other: Any?): Boolean {\n\t\treturn if (other is ModInt) v == other.v else false\n\t}\n\toverride fun hashCode() = 31*17 + v.hashCode()\n\n\toperator fun unaryPlus() = this\n\toperator fun unaryMinus() = ModInt(MOD-this.v)\n\n\tprivate operator fun plus(o: Long) = ModInt(this.v + o)\n\toperator fun plus(o: ModInt) = this.plus(o.v)\n\toperator fun plus(o: Int) = this.plus(o.toLong())\n\tprivate operator fun minus(o: Long) = this.plus(-o)\n\toperator fun minus(o: ModInt) = this.minus(o.v)\n\toperator fun minus(o: Int) = this.minus(o.toLong())\n\tprivate operator fun times(o: Long) = ModInt(this.v*o)\n\toperator fun times(o: ModInt) = this.times(o.v)\n\toperator fun times(o: Int) = this.times(o.toLong())\n\tprivate operator fun div(o: Long) = this.times(pow(o, MOD-2))\n\toperator fun div(o: ModInt) = this.div(o.v)\n\toperator fun div(o: Int) = this.div(o.toLong())\n\n\toperator fun inc() = this.plus(1)\n\toperator fun dec() = this.minus(1)\n\n\tcompanion object{\n\t\tconst val MOD = 1000000007\n\n\t\tprivate fun pow(b:Long, e: Int): ModInt{\n\t\t\tif (b==1L) return ModInt(1)\n\t\t\tvar ans = 1L\n\t\t\tvar b = b; var e = e\n\t\t\twhile (e!=0){\n\t\t\t\tif (e%2==1) ans = (ans*b)%MOD\n\t\t\t\tb = (b*b)%MOD\n\t\t\t\te /= 2\n\t\t\t}\n\t\t\treturn ModInt(ans)\n\t\t}\n\t\tfun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)\n\t\tfun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)\n\t}\n}\n", "language": "Kotlin", "metadata": {"date": 1592794426, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02632.html", "problem_id": "p02632", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02632/input.txt", "sample_output_relpath": "derived/input_output/data/p02632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02632/Kotlin/s632775476.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s632775476", "user_id": "u914590612"}, "prompt_components": {"gold_output": "575111451\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main() {\n\tval scn = Scanner(System.`in`)\n\tval k = scn.nextInt()\n\tval s = scn.next()\n\tval l = s.length\n\tval f = mutableListOf(ModInt(1))\n\tfor (i in 1..l+k){\n\t\tf.add(f.last()*i)\n\t}\n\tval bef = Array(k+1){ModInt.pow(25, it)*f[l-1+it]/(f[it]*f[l-1])}\n\tval arr = mutableListOf(ModInt(1))\n\tfor (c in 1..k){\n\t\tarr.add(arr.last()*26+bef[c])\n\t}\n\tprintln(arr.last())\n}\n\nclass ModInt {\n\tvar v: Long\n\t\tprivate set\n\tconstructor(v: Int){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v.toLong() % MOD\n\t\t\tv==Int.MIN_VALUE -> 852516373\n\t\t\telse -> MOD.toLong() - (-v%MOD)\n\t\t}\n\t}\n\tconstructor(v: Long){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v % MOD\n\t\t\tv==Long.MIN_VALUE -> 708828003\n\t\t\telse -> MOD - (-v%MOD)\n\t\t}\n\t}\n\n\toverride fun toString() = v.toString()\n\tfun toInt() = v.toInt()\n\tfun toLong() = v\n\toverride fun equals(other: Any?): Boolean {\n\t\treturn if (other is ModInt) v == other.v else false\n\t}\n\toverride fun hashCode() = 31*17 + v.hashCode()\n\n\toperator fun unaryPlus() = this\n\toperator fun unaryMinus() = ModInt(MOD-this.v)\n\n\tprivate operator fun plus(o: Long) = ModInt(this.v + o)\n\toperator fun plus(o: ModInt) = this.plus(o.v)\n\toperator fun plus(o: Int) = this.plus(o.toLong())\n\tprivate operator fun minus(o: Long) = this.plus(-o)\n\toperator fun minus(o: ModInt) = this.minus(o.v)\n\toperator fun minus(o: Int) = this.minus(o.toLong())\n\tprivate operator fun times(o: Long) = ModInt(this.v*o)\n\toperator fun times(o: ModInt) = this.times(o.v)\n\toperator fun times(o: Int) = this.times(o.toLong())\n\tprivate operator fun div(o: Long) = this.times(pow(o, MOD-2))\n\toperator fun div(o: ModInt) = this.div(o.v)\n\toperator fun div(o: Int) = this.div(o.toLong())\n\n\toperator fun inc() = this.plus(1)\n\toperator fun dec() = this.minus(1)\n\n\tcompanion object{\n\t\tconst val MOD = 1000000007\n\n\t\tprivate fun pow(b:Long, e: Int): ModInt{\n\t\t\tif (b==1L) return ModInt(1)\n\t\t\tvar ans = 1L\n\t\t\tvar b = b; var e = e\n\t\t\twhile (e!=0){\n\t\t\t\tif (e%2==1) ans = (ans*b)%MOD\n\t\t\t\tb = (b*b)%MOD\n\t\t\t\te /= 2\n\t\t\t}\n\t\t\treturn ModInt(ans)\n\t\t}\n\t\tfun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)\n\t\tfun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)\n\t}\n}\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+7).\n\nConstraints\n\nK is an integer between 1 and 10^6 (inclusive).\n\nS is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint the number of strings satisfying the condition, modulo (10^9+7).\n\nSample Input 1\n\n5\noof\n\nSample Output 1\n\n575111451\n\nFor example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.\n\nSample Input 2\n\n37564\nwhydidyoudesertme\n\nSample Output 2\n\n318008117", "sample_input": "5\noof\n"}, "reference_outputs": ["575111451\n"], "source_document_id": "p02632", "source_text": "Score: 600 points\n\nProblem Statement\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+7).\n\nConstraints\n\nK is an integer between 1 and 10^6 (inclusive).\n\nS is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint the number of strings satisfying the condition, modulo (10^9+7).\n\nSample Input 1\n\n5\noof\n\nSample Output 1\n\n575111451\n\nFor example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.\n\nSample Input 2\n\n37564\nwhydidyoudesertme\n\nSample Output 2\n\n318008117", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2101, "cpu_time_ms": 895, "memory_kb": 163596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s648957710", "group_id": "codeNet:p02639", "input_text": "fun main() {\n val xs = readLine()!!.split(' ')\n print(xs.indexOf(\"0\"))\n}", "language": "Kotlin", "metadata": {"date": 1598276688, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/Kotlin/s648957710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s648957710", "user_id": "u455317716"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val xs = readLine()!!.split(' ')\n print(xs.indexOf(\"0\"))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 78, "cpu_time_ms": 105, "memory_kb": 35700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s558905639", "group_id": "codeNet:p02639", "input_text": "fun main() {\n val (x1, x2, x3, x4, x5) = readLine()!!.split(\" \").map{it.toInt()}\n\n if (x1 == 0){\n println(\"1\")\n } else if (x2 == 0){\n println(\"2\")\n } else if (x3 == 0){\n println(\"3\")\n } else if (x4 == 0){\n println(\"4\")\n } else if (x5 == 0){\n println(\"5\")\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1592186235, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/Kotlin/s558905639.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558905639", "user_id": "u319722345"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n val (x1, x2, x3, x4, x5) = readLine()!!.split(\" \").map{it.toInt()}\n\n if (x1 == 0){\n println(\"1\")\n } else if (x2 == 0){\n println(\"2\")\n } else if (x3 == 0){\n println(\"3\")\n } else if (x4 == 0){\n println(\"4\")\n } else if (x5 == 0){\n println(\"5\")\n }\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 316, "cpu_time_ms": 106, "memory_kb": 36444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s634359975", "group_id": "codeNet:p02639", "input_text": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map(String::toInt)\nprivate fun readStrings2() = readLn().split(\"\").filter { it.isNotEmpty() }\nprivate fun readInts2() = readStrings2().map(String::toInt)\nprivate fun initArray(n:Int, v:String) = Array(n) { v }\nprivate fun initIntArray(n:Int, v:Int) = IntArray(n) { v }\n\nfun main(args: Array) {\n val x = readInts()\n\n repeat(x.size) { idx ->\n if(x[idx] == 0) println(\"${idx + 1}\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1592183162, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/Kotlin/s634359975.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s634359975", "user_id": "u371560174"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "private fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map(String::toInt)\nprivate fun readStrings2() = readLn().split(\"\").filter { it.isNotEmpty() }\nprivate fun readInts2() = readStrings2().map(String::toInt)\nprivate fun initArray(n:Int, v:String) = Array(n) { v }\nprivate fun initIntArray(n:Int, v:Int) = IntArray(n) { v }\n\nfun main(args: Array) {\n val x = readInts()\n\n repeat(x.size) { idx ->\n if(x[idx] == 0) println(\"${idx + 1}\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 571, "cpu_time_ms": 98, "memory_kb": 36308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s090685638", "group_id": "codeNet:p02639", "input_text": "fun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d:String = \" \") = str().split(d)\nfun list(d:String = \" \",f:String.()->T) = read(d).map {f(it)}\nfun list() = list {toInt()}.toIntArray()\n\nfun T.print() = println(this)\n\nfun main() {\n\tabc000X()\n}\n\nfun abc000X() {\n\tprintln(list().indexOf(0)+1)\n}\n", "language": "Kotlin", "metadata": {"date": 1592182875, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/Kotlin/s090685638.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s090685638", "user_id": "u059234158"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun str() = readLine()!!\nfun int() = str().toInt()\nfun long() = str().toLong()\n\nfun read(d:String = \" \") = str().split(d)\nfun list(d:String = \" \",f:String.()->T) = read(d).map {f(it)}\nfun list() = list {toInt()}.toIntArray()\n\nfun T.print() = println(this)\n\nfun main() {\n\tabc000X()\n}\n\nfun abc000X() {\n\tprintln(list().indexOf(0)+1)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 121, "memory_kb": 40112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s187446714", "group_id": "codeNet:p02640", "input_text": "fun main(args: Array) {\n val (X, Y) = readLine()!!.split(\" \").map{it.toInt()}\n \n fun calcLegNum(tartle: Int, total: Int = Y): String {\n return if(tartle == total) \"Yes\" else if(tartle < 2) \"No\" else calcLegNum(tartle - 2)\n }\n val tartleLeg = X * 4\n val result = if(Y % 2 != 0 || tartleLeg < Y) \"No\" else calcLegNum(tartleLeg)\n \n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1600035793, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02640/input.txt", "sample_output_relpath": "derived/input_output/data/p02640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02640/Kotlin/s187446714.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s187446714", "user_id": "u496449946"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (X, Y) = readLine()!!.split(\" \").map{it.toInt()}\n \n fun calcLegNum(tartle: Int, total: Int = Y): String {\n return if(tartle == total) \"Yes\" else if(tartle < 2) \"No\" else calcLegNum(tartle - 2)\n }\n val tartleLeg = X * 4\n val result = if(Y % 2 != 0 || tartleLeg < Y) \"No\" else calcLegNum(tartleLeg)\n \n println(result)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 365, "cpu_time_ms": 112, "memory_kb": 36464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s963001168", "group_id": "codeNet:p02640", "input_text": "fun main() {\n var answer = \"No\"\n\n val XY = readLine()!!.split(\" \").map { it.toInt() }\n val X = XY[0]\n val Y = XY[1]\n\n for (c in 0..X) {\n if (4*X - 2*c == Y) {\n answer = \"Yes\"\n break\n }\n }\n\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1596625877, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02640/input.txt", "sample_output_relpath": "derived/input_output/data/p02640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02640/Kotlin/s963001168.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963001168", "user_id": "u437444592"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main() {\n var answer = \"No\"\n\n val XY = readLine()!!.split(\" \").map { it.toInt() }\n val X = XY[0]\n val Y = XY[1]\n\n for (c in 0..X) {\n if (4*X - 2*c == Y) {\n answer = \"Yes\"\n break\n }\n }\n\n println(answer)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 264, "cpu_time_ms": 111, "memory_kb": 36348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s960062103", "group_id": "codeNet:p02640", "input_text": "import kotlin.math.*\nimport kotlin.system.exitProcess\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() //single long\nprivate fun readDouble() = readLn().toDouble()\n\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() }\n\nfun main(){\n val (x, y) = readDoubles()\n\n val t: Double = (y-2*x)/2\n val c: Double = x-t\n\n if(t<0 || c < 0){\n println(\"No\")\n exitProcess(0)\n }\n\n if (t%1 == 0.0 && c%1 ==0.0){\n println(\"Yes\")\n }\n else{\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592184743, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02640/input.txt", "sample_output_relpath": "derived/input_output/data/p02640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02640/Kotlin/s960062103.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s960062103", "user_id": "u059982665"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import kotlin.math.*\nimport kotlin.system.exitProcess\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() //single long\nprivate fun readDouble() = readLn().toDouble()\n\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() }\n\nfun main(){\n val (x, y) = readDoubles()\n\n val t: Double = (y-2*x)/2\n val c: Double = x-t\n\n if(t<0 || c < 0){\n println(\"No\")\n exitProcess(0)\n }\n\n if (t%1 == 0.0 && c%1 ==0.0){\n println(\"Yes\")\n }\n else{\n println(\"No\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 822, "cpu_time_ms": 103, "memory_kb": 36572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s683679744", "group_id": "codeNet:p02640", "input_text": "fun main(args: Array) {\n val (X, Y) = readLine()!!.split(\" \").map { it.toInt() }\n\n for (a in 1..100) {\n for (b in 0..100) {\n if ((a+b)==X && (2*a+4*b)==Y) {\n println(\"Yes\")\n return\n }\n }\n }\n println(\"No\")\n\n}", "language": "Kotlin", "metadata": {"date": 1592183488, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02640/input.txt", "sample_output_relpath": "derived/input_output/data/p02640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02640/Kotlin/s683679744.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s683679744", "user_id": "u727736935"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (X, Y) = readLine()!!.split(\" \").map { it.toInt() }\n\n for (a in 1..100) {\n for (b in 0..100) {\n if ((a+b)==X && (2*a+4*b)==Y) {\n println(\"Yes\")\n return\n }\n }\n }\n println(\"No\")\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 293, "cpu_time_ms": 97, "memory_kb": 36384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s057724262", "group_id": "codeNet:p02641", "input_text": "import kotlin.math.abs\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n val (x, n) = readIntList()\n if (n == 0) {\n println(x)\n return\n }\n val p = readIntList()\n\n val numMap = Array(101) { 0 }\n p.forEach {\n numMap[it] += 1\n }\n\n val absList = Array(101) { 0 }\n absList[0] = 500\n absList.forEachIndexed { index, i ->\n if (numMap[index] == 0) {\n absList[index] = abs(index - x)\n } else {\n absList[index] = 500\n }\n }\n\n var res = 100\n var minValue = 500\n absList.slice(1 until absList.size).reversed().forEachIndexed { index, i ->\n if (minValue >= i) {\n res = 100 - index\n minValue = i\n }\n }\n println(res)\n}\n", "language": "Kotlin", "metadata": {"date": 1592805147, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/Kotlin/s057724262.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057724262", "user_id": "u657541767"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import kotlin.math.abs\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n val (x, n) = readIntList()\n if (n == 0) {\n println(x)\n return\n }\n val p = readIntList()\n\n val numMap = Array(101) { 0 }\n p.forEach {\n numMap[it] += 1\n }\n\n val absList = Array(101) { 0 }\n absList[0] = 500\n absList.forEachIndexed { index, i ->\n if (numMap[index] == 0) {\n absList[index] = abs(index - x)\n } else {\n absList[index] = 500\n }\n }\n\n var res = 100\n var minValue = 500\n absList.slice(1 until absList.size).reversed().forEachIndexed { index, i ->\n if (minValue >= i) {\n res = 100 - index\n minValue = i\n }\n }\n println(res)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1051, "cpu_time_ms": 139, "memory_kb": 40584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s723061996", "group_id": "codeNet:p02641", "input_text": "fun main(args: Array) {\n val (check, numCount) = readLine()!!.split(' ').map { it.toInt() }\n if(numCount == 0) {\n println(check)\n return\n }\n if(numCount == 100) {\n println(\"0\")\n return\n }\n var numbers = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n\n var mostLowerResent = 0\n var mostUpperResent = 100\n var lowerDiff = 100\n var upperDiff = 100\n\n\n for (i in 1..100) {\n if (numbers.contains(i)) continue\n if(i == check) {\n println(check)\n return\n }\n if (i < check) {\n mostLowerResent = i\n lowerDiff = check - mostLowerResent\n } else {\n mostUpperResent = i\n upperDiff = mostUpperResent - check\n if (lowerDiff >= upperDiff) {\n break\n }\n }\n }\n\n if (lowerDiff <= upperDiff) {\n println(mostLowerResent)\n } else {\n println(mostUpperResent)\n }\n }", "language": "Kotlin", "metadata": {"date": 1592187987, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/Kotlin/s723061996.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s723061996", "user_id": "u157933935"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val (check, numCount) = readLine()!!.split(' ').map { it.toInt() }\n if(numCount == 0) {\n println(check)\n return\n }\n if(numCount == 100) {\n println(\"0\")\n return\n }\n var numbers = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n\n var mostLowerResent = 0\n var mostUpperResent = 100\n var lowerDiff = 100\n var upperDiff = 100\n\n\n for (i in 1..100) {\n if (numbers.contains(i)) continue\n if(i == check) {\n println(check)\n return\n }\n if (i < check) {\n mostLowerResent = i\n lowerDiff = check - mostLowerResent\n } else {\n mostUpperResent = i\n upperDiff = mostUpperResent - check\n if (lowerDiff >= upperDiff) {\n break\n }\n }\n }\n\n if (lowerDiff <= upperDiff) {\n println(mostLowerResent)\n } else {\n println(mostUpperResent)\n }\n }", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1134, "cpu_time_ms": 123, "memory_kb": 40212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s754862180", "group_id": "codeNet:p02641", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val x = sc.nextInt()\n val n = sc.nextInt()\n val p = (1..n).map { sc.nextInt() }\n\n if (n == 0) {\n println(x)\n return\n }\n\n var index = x\n var diff = Integer.MAX_VALUE\n for (i in 1..100) {\n if (p.contains(i)) {\n continue\n }\n\n val tmp = Math.abs(x - i)\n if (tmp < diff) {\n diff = tmp\n index = i\n }\n }\n\n println(index)\n}\n", "language": "Kotlin", "metadata": {"date": 1592184644, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/Kotlin/s754862180.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s754862180", "user_id": "u323522006"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val x = sc.nextInt()\n val n = sc.nextInt()\n val p = (1..n).map { sc.nextInt() }\n\n if (n == 0) {\n println(x)\n return\n }\n\n var index = x\n var diff = Integer.MAX_VALUE\n for (i in 1..100) {\n if (p.contains(i)) {\n continue\n }\n\n val tmp = Math.abs(x - i)\n if (tmp < diff) {\n diff = tmp\n index = i\n }\n }\n\n println(index)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 140, "memory_kb": 37668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s080289104", "group_id": "codeNet:p02641", "input_text": "fun main(args: Array) {\n val x = readLine()!!.split(\" \").map { it.toInt() }\n val x2 = x.first()\n val line = readLine()\n if (line.isNullOrBlank()) {\n return println(x2)\n }\n val p = line!!.split(\" \").map { it.toInt() }\n for (i in 0..Int.MAX_VALUE)\n if (!p.contains(x2 - i)) {\n return println(x2 - i)\n } else if (!p.contains(x2 + i)) {\n return println(x2 + i)\n }\n }\n\n", "language": "Kotlin", "metadata": {"date": 1592183983, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/Kotlin/s080289104.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s080289104", "user_id": "u172820018"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.split(\" \").map { it.toInt() }\n val x2 = x.first()\n val line = readLine()\n if (line.isNullOrBlank()) {\n return println(x2)\n }\n val p = line!!.split(\" \").map { it.toInt() }\n for (i in 0..Int.MAX_VALUE)\n if (!p.contains(x2 - i)) {\n return println(x2 - i)\n } else if (!p.contains(x2 + i)) {\n return println(x2 + i)\n }\n }\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 446, "cpu_time_ms": 115, "memory_kb": 36668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s642100580", "group_id": "codeNet:p02641", "input_text": "fun main(args: Array) {\n val (x,_) = readLine()!!.split(\" \").map { it.toInt() }\n val line = readLine() ?: return println(x)\n val p = line.split(\" \").map { it.toInt() }\n var index = 0\n while (true) {\n if (!p.contains(x - index)) {\n return println(x - index)\n } else if (!p.contains(x + index)) {\n return println(x + index)\n }\n index++\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592183520, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/Kotlin/s642100580.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s642100580", "user_id": "u172820018"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val (x,_) = readLine()!!.split(\" \").map { it.toInt() }\n val line = readLine() ?: return println(x)\n val p = line.split(\" \").map { it.toInt() }\n var index = 0\n while (true) {\n if (!p.contains(x - index)) {\n return println(x - index)\n } else if (!p.contains(x + index)) {\n return println(x + index)\n }\n index++\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 99, "memory_kb": 36412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s770148475", "group_id": "codeNet:p02644", "input_text": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.Reader\nimport java.util.*\n\nprivate val scanner = BufferedScanner()\nprivate fun readLn() = scanner.nextLine() // 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() }\n\nconst val INF = 1e9.toInt()\n\n@ExperimentalStdlibApi\nfun main() {\n val timer = System.nanoTime()\n val (h, w, k) = readInts()\n val (x1, y1, x2, y2) = readInts().map { it - 1 }\n val grid = Array(h) { \"\" }\n repeat(h) {\n grid[it] = readLn()\n }\n val shortest = Array(h) { IntArray(w) { INF } }\n val q = mutableListOf>()\n var p = 0\n q.add(x1 to y1)\n shortest[x1][y1] = 0\n val rows = Array(h) { r ->\n (0 until w).filterNot { c -> grid[r][c] == '@' }.toTreeSet()\n }\n val cols = Array(w) { c ->\n (0 until h).filterNot { r -> grid[r][c] == '@' }.toTreeSet()\n }\n val rowPref = Array(h) { r ->\n (0 until w).scan(0, { acc, c ->\n acc + if (grid[r][c] == '@') 1 else 0\n })\n }\n val colPref = Array(w) { c ->\n (0 until h).scan(0, { acc, r ->\n acc + if (grid[r][c] == '@') 1 else 0\n })\n }\n System.err.println(\"init finished: \" + ((System.nanoTime() - timer) / 1e9))\n val timer2 = System.nanoTime()\n rows[x1].remove(y1)\n cols[y1].remove(x1)\n while (p < q.size) {\n val (x, y) = q[p++]\n if (x == x2 && y == y2) {\n break\n }\n val it1 = rows[x].tailSet(y, false).iterator()\n while (it1.hasNext()) {\n val yy = it1.next()\n if (y + k < yy || rowPref[x][y] != rowPref[x][yy + 1]) {\n break\n }\n q.add(x to yy)\n shortest[x][yy] = shortest[x][y] + 1\n it1.remove()\n cols[yy].remove(x)\n }\n val it2 = rows[x].headSet(y, false).descendingIterator()\n while (it2.hasNext()) {\n val yy = it2.next()\n if (yy + k < y || rowPref[x][y + 1] != rowPref[x][yy]) {\n break\n }\n q.add(x to yy)\n shortest[x][yy] = shortest[x][y] + 1\n it2.remove()\n cols[yy].remove(x)\n }\n val it3 = cols[y].tailSet(x, false).iterator()\n while (it3.hasNext()) {\n val xx = it3.next()\n if (x + k < xx || colPref[y][x] != colPref[y][xx + 1]) {\n break\n }\n q.add(xx to y)\n shortest[xx][y] = shortest[x][y] + 1\n it3.remove()\n rows[xx].remove(y)\n }\n val it4 = cols[y].headSet(x, false).descendingIterator()\n while (it4.hasNext()) {\n val xx = it4.next()\n if (xx + k < x || colPref[y][x + 1] != colPref[y][xx]) {\n break\n }\n q.add(xx to y)\n shortest[xx][y] = shortest[x][y] + 1\n it4.remove()\n rows[xx].remove(y)\n }\n }\n println(if (shortest[x2][y2] == INF) -1 else shortest[x2][y2])\n System.err.println(\"job finished: \" + ((System.nanoTime() - timer2) / 1e9))\n}\n\nprivate fun Iterable.toTreeSet(): TreeSet {\n val s = TreeSet()\n forEach { s.add(it) }\n return s\n}\n\nclass BufferedScanner @JvmOverloads constructor(reader: Reader? = InputStreamReader(System.`in`)) {\n var br: BufferedReader = BufferedReader(reader, 1 shl 20)\n var st: StringTokenizer? = null\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 return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return next().toInt()\n }\n\n fun nextLong(): Long {\n return next().toLong()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun close() {\n try {\n br.close()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1592419020, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02644.html", "problem_id": "p02644", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02644/input.txt", "sample_output_relpath": "derived/input_output/data/p02644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02644/Kotlin/s770148475.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s770148475", "user_id": "u874259320"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.Reader\nimport java.util.*\n\nprivate val scanner = BufferedScanner()\nprivate fun readLn() = scanner.nextLine() // 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() }\n\nconst val INF = 1e9.toInt()\n\n@ExperimentalStdlibApi\nfun main() {\n val timer = System.nanoTime()\n val (h, w, k) = readInts()\n val (x1, y1, x2, y2) = readInts().map { it - 1 }\n val grid = Array(h) { \"\" }\n repeat(h) {\n grid[it] = readLn()\n }\n val shortest = Array(h) { IntArray(w) { INF } }\n val q = mutableListOf>()\n var p = 0\n q.add(x1 to y1)\n shortest[x1][y1] = 0\n val rows = Array(h) { r ->\n (0 until w).filterNot { c -> grid[r][c] == '@' }.toTreeSet()\n }\n val cols = Array(w) { c ->\n (0 until h).filterNot { r -> grid[r][c] == '@' }.toTreeSet()\n }\n val rowPref = Array(h) { r ->\n (0 until w).scan(0, { acc, c ->\n acc + if (grid[r][c] == '@') 1 else 0\n })\n }\n val colPref = Array(w) { c ->\n (0 until h).scan(0, { acc, r ->\n acc + if (grid[r][c] == '@') 1 else 0\n })\n }\n System.err.println(\"init finished: \" + ((System.nanoTime() - timer) / 1e9))\n val timer2 = System.nanoTime()\n rows[x1].remove(y1)\n cols[y1].remove(x1)\n while (p < q.size) {\n val (x, y) = q[p++]\n if (x == x2 && y == y2) {\n break\n }\n val it1 = rows[x].tailSet(y, false).iterator()\n while (it1.hasNext()) {\n val yy = it1.next()\n if (y + k < yy || rowPref[x][y] != rowPref[x][yy + 1]) {\n break\n }\n q.add(x to yy)\n shortest[x][yy] = shortest[x][y] + 1\n it1.remove()\n cols[yy].remove(x)\n }\n val it2 = rows[x].headSet(y, false).descendingIterator()\n while (it2.hasNext()) {\n val yy = it2.next()\n if (yy + k < y || rowPref[x][y + 1] != rowPref[x][yy]) {\n break\n }\n q.add(x to yy)\n shortest[x][yy] = shortest[x][y] + 1\n it2.remove()\n cols[yy].remove(x)\n }\n val it3 = cols[y].tailSet(x, false).iterator()\n while (it3.hasNext()) {\n val xx = it3.next()\n if (x + k < xx || colPref[y][x] != colPref[y][xx + 1]) {\n break\n }\n q.add(xx to y)\n shortest[xx][y] = shortest[x][y] + 1\n it3.remove()\n rows[xx].remove(y)\n }\n val it4 = cols[y].headSet(x, false).descendingIterator()\n while (it4.hasNext()) {\n val xx = it4.next()\n if (xx + k < x || colPref[y][x + 1] != colPref[y][xx]) {\n break\n }\n q.add(xx to y)\n shortest[xx][y] = shortest[x][y] + 1\n it4.remove()\n rows[xx].remove(y)\n }\n }\n println(if (shortest[x2][y2] == INF) -1 else shortest[x2][y2])\n System.err.println(\"job finished: \" + ((System.nanoTime() - timer2) / 1e9))\n}\n\nprivate fun Iterable.toTreeSet(): TreeSet {\n val s = TreeSet()\n forEach { s.add(it) }\n return s\n}\n\nclass BufferedScanner @JvmOverloads constructor(reader: Reader? = InputStreamReader(System.`in`)) {\n var br: BufferedReader = BufferedReader(reader, 1 shl 20)\n var st: StringTokenizer? = null\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 return st!!.nextToken()\n }\n\n fun nextInt(): Int {\n return next().toInt()\n }\n\n fun nextLong(): Long {\n return next().toLong()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun nextLine(): String {\n var str = \"\"\n try {\n str = br.readLine()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n return str\n }\n\n fun close() {\n try {\n br.close()\n } catch (e: IOException) {\n e.printStackTrace()\n }\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "sample_input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02644", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4514, "cpu_time_ms": 3163, "memory_kb": 465564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s028178828", "group_id": "codeNet:p02645", "input_text": "fun main(args:Array){\n val S = readLine()!!\n println(S.substring(0, 3))\n}", "language": "Kotlin", "metadata": {"date": 1592096874, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02645.html", "problem_id": "p02645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02645/input.txt", "sample_output_relpath": "derived/input_output/data/p02645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02645/Kotlin/s028178828.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s028178828", "user_id": "u035856025"}, "prompt_components": {"gold_output": "tak\n", "input_to_evaluate": "fun main(args:Array){\n val S = readLine()!!\n println(S.substring(0, 3))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWhen you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters.\nYou have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.\n\nConstraints\n\n3 \\leq |S| \\leq 20\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint your answer.\n\nSample Input 1\n\ntakahashi\n\nSample Output 1\n\ntak\n\nSample Input 2\n\nnaohiro\n\nSample Output 2\n\nnao", "sample_input": "takahashi\n"}, "reference_outputs": ["tak\n"], "source_document_id": "p02645", "source_text": "Score : 100 points\n\nProblem Statement\n\nWhen you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters.\nYou have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.\n\nConstraints\n\n3 \\leq |S| \\leq 20\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint your answer.\n\nSample Input 1\n\ntakahashi\n\nSample Output 1\n\ntak\n\nSample Input 2\n\nnaohiro\n\nSample Output 2\n\nnao", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 87, "cpu_time_ms": 88, "memory_kb": 34548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s688660430", "group_id": "codeNet:p02645", "input_text": "\n\nfun main(args: Array) {\n\n var S = readLine()!!.toString()\n\n println(S.subSequence(0, 3))\n\n}", "language": "Kotlin", "metadata": {"date": 1592096554, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02645.html", "problem_id": "p02645", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02645/input.txt", "sample_output_relpath": "derived/input_output/data/p02645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02645/Kotlin/s688660430.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s688660430", "user_id": "u727736935"}, "prompt_components": {"gold_output": "tak\n", "input_to_evaluate": "\n\nfun main(args: Array) {\n\n var S = readLine()!!.toString()\n\n println(S.subSequence(0, 3))\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWhen you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters.\nYou have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.\n\nConstraints\n\n3 \\leq |S| \\leq 20\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint your answer.\n\nSample Input 1\n\ntakahashi\n\nSample Output 1\n\ntak\n\nSample Input 2\n\nnaohiro\n\nSample Output 2\n\nnao", "sample_input": "takahashi\n"}, "reference_outputs": ["tak\n"], "source_document_id": "p02645", "source_text": "Score : 100 points\n\nProblem Statement\n\nWhen you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters.\nYou have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.\n\nConstraints\n\n3 \\leq |S| \\leq 20\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint your answer.\n\nSample Input 1\n\ntakahashi\n\nSample Output 1\n\ntak\n\nSample Input 2\n\nnaohiro\n\nSample Output 2\n\nnao", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 107, "cpu_time_ms": 81, "memory_kb": 34312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s682865019", "group_id": "codeNet:p02646", "input_text": "fun main(args: Array) {\n val (a,v) = readLine()!!.split(\" \").map { it.toLong() }\n val (b,w) = readLine()!!.split(\" \").map { it.toLong() }\n val t= readLine()!!.toLong()\n\n var tmpA = a\n var tmpB = b\n val moveToRight = a < b\n\n val touchable = if (a < b) {\n w < v\n } else v < w\n println(if (touchable) \"YES\" else \"NO\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1592098447, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/Kotlin/s682865019.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s682865019", "user_id": "u381359012"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (a,v) = readLine()!!.split(\" \").map { it.toLong() }\n val (b,w) = readLine()!!.split(\" \").map { it.toLong() }\n val t= readLine()!!.toLong()\n\n var tmpA = a\n var tmpB = b\n val moveToRight = a < b\n\n val touchable = if (a < b) {\n w < v\n } else v < w\n println(if (touchable) \"YES\" else \"NO\")\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 106, "memory_kb": 36396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s088862696", "group_id": "codeNet:p02646", "input_text": "fun main(args: Array) {\n val (aStart, aSpeed) = readLine()!!.split(' ').map{it.toInt()}\n val (bStart, bSpeed) = readLine()!!.split(' ').map{it.toInt()}\n val time = readLine()!!.toInt()\n\n if(aStart == bStart) {\n println(\"YES\")\n return\n }\n\n if(aStart < bStart) {\n val aPosition = aStart + (aSpeed * time)\n val bPosition = bStart + (bSpeed * time)\n\n if(aPosition - bPosition > 0) {\n println(\"YES\")\n return\n } else {\n println(\"NO\")\n }\n } else {\n val aPosition = aStart - (aSpeed * time)\n val bPosition = bStart - (bSpeed * time)\n\n if(aPosition - bPosition < 0) {\n println(\"YES\")\n return\n } else {\n println(\"NO\")\n }\n }\n }", "language": "Kotlin", "metadata": {"date": 1592097783, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/Kotlin/s088862696.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s088862696", "user_id": "u157933935"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (aStart, aSpeed) = readLine()!!.split(' ').map{it.toInt()}\n val (bStart, bSpeed) = readLine()!!.split(' ').map{it.toInt()}\n val time = readLine()!!.toInt()\n\n if(aStart == bStart) {\n println(\"YES\")\n return\n }\n\n if(aStart < bStart) {\n val aPosition = aStart + (aSpeed * time)\n val bPosition = bStart + (bSpeed * time)\n\n if(aPosition - bPosition > 0) {\n println(\"YES\")\n return\n } else {\n println(\"NO\")\n }\n } else {\n val aPosition = aStart - (aSpeed * time)\n val bPosition = bStart - (bSpeed * time)\n\n if(aPosition - bPosition < 0) {\n println(\"YES\")\n return\n } else {\n println(\"NO\")\n }\n }\n }", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 937, "cpu_time_ms": 99, "memory_kb": 36356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s873881456", "group_id": "codeNet:p02647", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\ndata class Segment(val begin: Int, val end: Int)\nclass Imos(val Segs: List) {\n var tm = LongArray(0)\n init {\n val N = Segs.maxBy { it.end }!!.end\n tm = LongArray(N + 4){0}\n for (seg in Segs) {\n tm[seg.begin] += 1L\n tm[seg.end] -= 1L\n }\n for (i in 0 until tm.size-1) {\n tm[i+1] += tm[i]\n }\n }\n}\n\nfun solve() {\n val (N, K) = rd.readListInt()\n val A = rd.readLongArray()\n\n val B= A.copyOf()\n for (k in 0 until K) {\n var updating = false\n\n val sgs = ArrayList()\n for (i in 0 until N) {\n sgs.add(\n Segment(max(0, i - B[i].toInt()), min(i + B[i].toInt()+1, N))\n )\n }\n\n val imos = Imos(sgs)\n\n for (i in 0 until N) {\n val b = imos.tm[i]\n if (B[i] != b) {\n updating = true\n B[i] =b\n }\n }\n if (!updating) break\n }\n\n val ans = B.joinToString(\" \")\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"tokiomarine2020\", \"c\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1599673318, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02647.html", "problem_id": "p02647", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02647/input.txt", "sample_output_relpath": "derived/input_output/data/p02647/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02647/Kotlin/s873881456.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s873881456", "user_id": "u404244809"}, "prompt_components": {"gold_output": "1 2 2 1 2\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\ndata class Segment(val begin: Int, val end: Int)\nclass Imos(val Segs: List) {\n var tm = LongArray(0)\n init {\n val N = Segs.maxBy { it.end }!!.end\n tm = LongArray(N + 4){0}\n for (seg in Segs) {\n tm[seg.begin] += 1L\n tm[seg.end] -= 1L\n }\n for (i in 0 until tm.size-1) {\n tm[i+1] += tm[i]\n }\n }\n}\n\nfun solve() {\n val (N, K) = rd.readListInt()\n val A = rd.readLongArray()\n\n val B= A.copyOf()\n for (k in 0 until K) {\n var updating = false\n\n val sgs = ArrayList()\n for (i in 0 until N) {\n sgs.add(\n Segment(max(0, i - B[i].toInt()), min(i + B[i].toInt()+1, N))\n )\n }\n\n val imos = Imos(sgs)\n\n for (i in 0 until N) {\n val b = imos.tm[i]\n if (B[i] != b) {\n updating = true\n B[i] =b\n }\n }\n if (!updating) break\n }\n\n val ans = B.joinToString(\" \")\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"etc\", \"tokiomarine2020\", \"c\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N bulbs arranged on a number line, numbered 1 to N from left to right.\nBulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity.\nWhen there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.\nInitially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:\n\nFor each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.\n\nFind the intensity of each bulb after the K operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:\n\nA{'}_1 A{'}_2 \\ldots A{'}_N\n\nSample Input 1\n\n5 1\n1 0 0 1 0\n\nSample Output 1\n\n1 2 2 1 2\n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.\nSimilarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\nSample Input 2\n\n5 2\n1 0 0 1 0\n\nSample Output 2\n\n3 3 4 4 3", "sample_input": "5 1\n1 0 0 1 0\n"}, "reference_outputs": ["1 2 2 1 2\n"], "source_document_id": "p02647", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N bulbs arranged on a number line, numbered 1 to N from left to right.\nBulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity.\nWhen there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.\nInitially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:\n\nFor each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.\n\nFind the intensity of each bulb after the K operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:\n\nA{'}_1 A{'}_2 \\ldots A{'}_N\n\nSample Input 1\n\n5 1\n1 0 0 1 0\n\nSample Output 1\n\n1 2 2 1 2\n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.\nSimilarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\nSample Input 2\n\n5 2\n1 0 0 1 0\n\nSample Output 2\n\n3 3 4 4 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3550, "cpu_time_ms": 792, "memory_kb": 102884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s781041843", "group_id": "codeNet:p02648", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n\n val V = IntArray(n+1)\n val W = IntArray(n+1)\n\n for(i in 1..n) {\n V[i] = readInt()\n W[i] = readInt()\n }\n\n val k = n.bitLength\n val h = (k+1)/2\n val m = (1 shl h) - 1\n\n val D = Array(m+1) { IntArray(maxL+1) }\n\n for(i in 1..m) {\n val p = i shr 1\n D[p].copyInto(D[i])\n for(j in W[i]..maxL) {\n D[i].setMax(j, D[p][j-W[i]] + V[i])\n }\n }\n\n val q = readInt()\n\n repeat(q) {\n var v = readInt()\n val l = readInt()\n\n val sz = 1 shl max(v.bitLength - h, 0)\n var csz = 1\n\n val vs = IntArray(sz)\n val ws = IntArray(sz)\n\n var ans = 0\n\n while(v > m) {\n for(i in 0 until csz) {\n vs[csz + i] = vs[i] + V[v]\n ws[csz + i] = ws[i] + W[v]\n }\n\n csz = csz shl 1\n v = v shr 1\n }\n\n for(i in vs.indices) {\n if(ws[i] <= l) ans = max(ans, D[v][l-ws[i]] + vs[i])\n }\n\n println(ans)\n }\n }\n}\n\nconst val maxL = 1e5.toInt()\n\ninline val Int.clz get() = Integer.numberOfLeadingZeros(this)\ninline val Long.clz get() = java.lang.Long.numberOfLeadingZeros(this)\ninline val Int.ctz get() = Integer.numberOfTrailingZeros(this)\ninline val Long.ctz get() = java.lang.Long.numberOfTrailingZeros(this)\nval Int.bitLength get() = 32 - clz\nval Long.bitLength get() = 64 - clz\n\nfun IntArray.setMax(i: Int, v: Int) = if(v > get(i)) { set(i, v); true } else false\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "language": "Kotlin", "metadata": {"date": 1592145175, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02648.html", "problem_id": "p02648", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02648/input.txt", "sample_output_relpath": "derived/input_output/data/p02648/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02648/Kotlin/s781041843.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s781041843", "user_id": "u596111103"}, "prompt_components": {"gold_output": "0\n3\n3\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n\n val V = IntArray(n+1)\n val W = IntArray(n+1)\n\n for(i in 1..n) {\n V[i] = readInt()\n W[i] = readInt()\n }\n\n val k = n.bitLength\n val h = (k+1)/2\n val m = (1 shl h) - 1\n\n val D = Array(m+1) { IntArray(maxL+1) }\n\n for(i in 1..m) {\n val p = i shr 1\n D[p].copyInto(D[i])\n for(j in W[i]..maxL) {\n D[i].setMax(j, D[p][j-W[i]] + V[i])\n }\n }\n\n val q = readInt()\n\n repeat(q) {\n var v = readInt()\n val l = readInt()\n\n val sz = 1 shl max(v.bitLength - h, 0)\n var csz = 1\n\n val vs = IntArray(sz)\n val ws = IntArray(sz)\n\n var ans = 0\n\n while(v > m) {\n for(i in 0 until csz) {\n vs[csz + i] = vs[i] + V[v]\n ws[csz + i] = ws[i] + W[v]\n }\n\n csz = csz shl 1\n v = v shr 1\n }\n\n for(i in vs.indices) {\n if(ws[i] <= l) ans = max(ans, D[v][l-ws[i]] + vs[i])\n }\n\n println(ans)\n }\n }\n}\n\nconst val maxL = 1e5.toInt()\n\ninline val Int.clz get() = Integer.numberOfLeadingZeros(this)\ninline val Long.clz get() = java.lang.Long.numberOfLeadingZeros(this)\ninline val Int.ctz get() = Integer.numberOfTrailingZeros(this)\ninline val Long.ctz get() = java.lang.Long.numberOfTrailingZeros(this)\nval Int.bitLength get() = 32 - clz\nval Long.bitLength get() = 64 - clz\n\nfun IntArray.setMax(i: Int, v: Int) = if(v > get(i)) { set(i, v); true } else false\n\nclass IntList(initialCapacity: Int = 12) {\n private var _arr = IntArray(initialCapacity)\n private val capacity get() = _arr.size\n var size = 0\n private set\n inline val lastIndex get() = size - 1\n inline val indices get() = 0 until size\n\n constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }\n constructor(copyFrom: Collection): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }\n\n fun contentEquals(other: IntList): Boolean {\n return this === other || size == other.size && indices.all { this[it] == other[it] }\n }\n\n private fun grow(minCapacity: Int = 8) {\n val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))\n _arr = _arr.copyOf(newCapacity)\n }\n\n fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }\n\n operator fun get(index: Int): Int {\n require(index in 0 until size)\n return _arr[index]\n }\n\n operator fun set(index: Int, value: Int) {\n require(index in 0 until size)\n _arr[index] = value\n }\n\n fun add(value: Int) {\n if(size == capacity) grow()\n _arr[size++] = value\n }\n\n fun add(index: Int, element: Int) {\n if(size == capacity) grow()\n _arr.copyInto(_arr, index + 1, index, size)\n size++\n set(index, element)\n }\n\n fun clear() { size = 0 }\n\n fun removeAt(index: Int): Int {\n val e = get(index)\n _arr.copyInto(_arr, index, index + 1, size)\n size--\n return e\n }\n\n operator fun iterator() = object: IntIterator() {\n private var pos = 0\n override fun hasNext() = pos < size\n override fun nextInt() = get(pos++)\n }\n\n inline fun isEmpty() = size == 0\n inline fun isNotEmpty() = size != 0\n\n fun pop() = _arr[--size]\n\n fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }\n fun reverse() {\n for(i in 0 until size / 2) swap(i, lastIndex - i)\n }\n\n fun shuffle(rnd: Random = random) = _shuffle(rnd, _arr::get, _arr::set, size)\n fun sort() { shuffle(); _arr._sort(0, size) }\n fun sortDescending() { sort(); reverse() }\n\n fun joinToString(separator: CharSequence) = if(size == 0) \"\" else let {\n buildString {\n append(it[0])\n for (i in 1 until size) {\n append(separator).append(it[i])\n }\n }\n }\n\n override fun toString() = \"[\" + joinToString(\", \") + \"]\"\n\n fun toIntArray() = _arr.copyOf(size)\n fun toList() = List(size, ::get)\n\n inline fun first() = get(0)\n inline fun last() = get(lastIndex)\n}\n\ninline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {\n for(i in 0 until size) { add(init(i)) }\n}\ninline fun IntArray.toIntList() = IntList(this)\ninline fun Collection.toIntList() = IntList(this)\ninline fun intListOf(vararg values: Int) = IntList(values)\n\nfun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }\nfun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }\nfun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null\ninline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }\nfun IntList.copyOf() = IntList(size, ::get)\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "sample_input": "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n"}, "reference_outputs": ["0\n3\n3\n"], "source_document_id": "p02648", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9289, "cpu_time_ms": 1668, "memory_kb": 384484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s848741010", "group_id": "codeNet:p02657", "input_text": "\n\nfun main(args: Array) {\n\n val list: List = readLine()!!.split(\" \").map{ it.toInt() }\n\n println(list[0] * list[1])\n}", "language": "Kotlin", "metadata": {"date": 1590973257, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02657/input.txt", "sample_output_relpath": "derived/input_output/data/p02657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02657/Kotlin/s848741010.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848741010", "user_id": "u727736935"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "\n\nfun main(args: Array) {\n\n val list: List = readLine()!!.split(\" \").map{ it.toInt() }\n\n println(list[0] * list[1])\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 103, "memory_kb": 36364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s909546924", "group_id": "codeNet:p02657", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val ans = readInt() * readInt()\n println(ans)\n }\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1590973232, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02657/input.txt", "sample_output_relpath": "derived/input_output/data/p02657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02657/Kotlin/s909546924.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909546924", "user_id": "u596111103"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val numCases = 1//readInt()\n for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val ans = readInt() * readInt()\n println(ans)\n }\n}\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(true) {\n when(c) {\n '\\n', Char.MIN_VALUE -> return@buildString\n else -> {\n append(c)\n c = readChar()\n }\n }\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4371, "cpu_time_ms": 79, "memory_kb": 34372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745069876", "group_id": "codeNet:p02660", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nfun primeFactorize(N: Long): Map {\n if (N <= 1L) return mapOf()\n val fact = mutableMapOf()\n var n = N\n var i = 2L\n while (i * i <= n) {\n while (n%i == 0L) {\n fact[i] = (fact[i] ?: 0) + 1\n n /= i\n }\n i++\n }\n if (n != 1L) {\n fact[n] = (fact[n] ?: 0) + 1\n }\n return fact\n}\n\n\nfun main() {\n val N = rd.readLong()\n\n val fs = primeFactorize(N).toMutableMap()\n\n var ans = 0\n var num = 1\n while (true) {\n var updated = false\n for ((k, v) in fs) {\n if (v >= num) {\n fs[k] = fs[k]!! - num\n ans++\n updated = true\n }\n }\n if (!updated) break\n num++\n }\n\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"169\", \"d\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nval EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "language": "Kotlin", "metadata": {"date": 1594429113, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02660/input.txt", "sample_output_relpath": "derived/input_output/data/p02660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02660/Kotlin/s745069876.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745069876", "user_id": "u404244809"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nfun primeFactorize(N: Long): Map {\n if (N <= 1L) return mapOf()\n val fact = mutableMapOf()\n var n = N\n var i = 2L\n while (i * i <= n) {\n while (n%i == 0L) {\n fact[i] = (fact[i] ?: 0) + 1\n n /= i\n }\n i++\n }\n if (n != 1L) {\n fact[n] = (fact[n] ?: 0) + 1\n }\n return fact\n}\n\n\nfun main() {\n val N = rd.readLong()\n\n val fs = primeFactorize(N).toMutableMap()\n\n var ans = 0\n var num = 1\n while (true) {\n var updated = false\n for ((k, v) in fs) {\n if (v >= num) {\n fs[k] = fs[k]!! - num\n ans++\n updated = true\n }\n }\n if (!updated) break\n num++\n }\n\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"169\", \"d\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nval EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "sample_input": "24\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02660", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2143, "cpu_time_ms": 119, "memory_kb": 35200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s066863510", "group_id": "codeNet:p02660", "input_text": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n if (n == 1L) {\n println(\"0\")\n return\n }\n var r = n\n var i = 2L\n val divs = mutableListOf()\n while (i * i < r) {\n if (r % i == 0L) {\n r /= i\n divs.add(i)\n } else {\n i++\n }\n }\n var count = 0\n if (r != 1L) {\n divs.add(1L)\n }\n divs.groupBy { it }\n .forEach { t, u ->\n var c = u.size\n var j = 1\n while (c >= j) {\n c -= j\n j++\n count++\n }\n }\n\n println(count.toString())\n}", "language": "Kotlin", "metadata": {"date": 1590981251, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02660/input.txt", "sample_output_relpath": "derived/input_output/data/p02660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02660/Kotlin/s066863510.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s066863510", "user_id": "u979429407"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n if (n == 1L) {\n println(\"0\")\n return\n }\n var r = n\n var i = 2L\n val divs = mutableListOf()\n while (i * i < r) {\n if (r % i == 0L) {\n r /= i\n divs.add(i)\n } else {\n i++\n }\n }\n var count = 0\n if (r != 1L) {\n divs.add(1L)\n }\n divs.groupBy { it }\n .forEach { t, u ->\n var c = u.size\n var j = 1\n while (c >= j) {\n c -= j\n j++\n count++\n }\n }\n\n println(count.toString())\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "sample_input": "24\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02660", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 661, "cpu_time_ms": 97, "memory_kb": 34612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s412473611", "group_id": "codeNet:p02660", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun Long.makePrimeMap(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun main(args: Array) {\n val n = readLong()\n\n\tval primeMap = n.makePrimeMap()\n\n\tval maxValue = primeMap.values.max()?:0\n\tval cSum = MutableList(maxValue+1) { 0L }\n\tfor(i in 1 .. maxValue) {\n\t\tcSum[i] = cSum[i-1] + i\n\t}\n\n\tvar cnt = 0\n\tprimeMap.values.forEach { v ->\n\t\tvar idx = maxValue \n\t\twhile(cSum[idx] > v) {\n\t\t\tidx--\n\t\t}\n\t\tcnt += idx\n\t}\n\tprintln(cnt)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1590976638, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02660/input.txt", "sample_output_relpath": "derived/input_output/data/p02660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02660/Kotlin/s412473611.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s412473611", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun Long.makePrimeMap(): Map {\n\tval map = mutableMapOf()\n\tvar num = this\n\tfor(i in 2L .. Math.sqrt(num.toDouble()).toLong()+1L) {\n\t\tif(num % i == 0L) {\n\t\t\twhile(num % i == 0L) {\n\t\t\t\tmap[i] = (map[i]?:0) + 1\n\t\t\t\tnum /= i\n\t\t\t}\n\t\t}\n\t}\n\tif(num != 1L) {\n\t\tmap[this] = 1 \n\t}\n\treturn map\n}\n\nfun main(args: Array) {\n val n = readLong()\n\n\tval primeMap = n.makePrimeMap()\n\n\tval maxValue = primeMap.values.max()?:0\n\tval cSum = MutableList(maxValue+1) { 0L }\n\tfor(i in 1 .. maxValue) {\n\t\tcSum[i] = cSum[i-1] + i\n\t}\n\n\tvar cnt = 0\n\tprimeMap.values.forEach { v ->\n\t\tvar idx = maxValue \n\t\twhile(cSum[idx] > v) {\n\t\t\tidx--\n\t\t}\n\t\tcnt += idx\n\t}\n\tprintln(cnt)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "sample_input": "24\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02660", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5790, "cpu_time_ms": 111, "memory_kb": 36744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s645906546", "group_id": "codeNet:p02661", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\nimport kotlin.math.sqrt\n\nval MOD = 1_000_000_007L\n\ndata class Entry(val a: Long, val b: Long)\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val E = Array(N) {Entry(nl(), nl())}\n val Ea = E.sortedBy { it.a }\n val Eb = E.sortedBy { -it.b }\n if (N % 2 == 1) {\n val l = Ea[N / 2].a\n val r = Eb[N / 2].b\n out.println(r - l + 1)\n } else {\n val l1 = Ea[N / 2 - 1].a\n val r1 = Eb[N / 2].b\n\n val l2 = Ea[N / 2].a\n val r2 = Eb[N / 2 - 1].b\n\n debug{\"$l1:$r1 $l2:$r2\"}\n\n out.println(r1 + r2 - (l1 + l2) + 1)\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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 // なんか本番でエラーでる\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 * 勝手にimport消されるのを防ぎたい\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}", "language": "Kotlin", "metadata": {"date": 1590975530, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02661/input.txt", "sample_output_relpath": "derived/input_output/data/p02661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02661/Kotlin/s645906546.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s645906546", "user_id": "u460609472"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.math.BigInteger\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\nimport kotlin.math.sqrt\n\nval MOD = 1_000_000_007L\n\ndata class Entry(val a: Long, val b: Long)\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = ni()\n val E = Array(N) {Entry(nl(), nl())}\n val Ea = E.sortedBy { it.a }\n val Eb = E.sortedBy { -it.b }\n if (N % 2 == 1) {\n val l = Ea[N / 2].a\n val r = Eb[N / 2].b\n out.println(r - l + 1)\n } else {\n val l1 = Ea[N / 2 - 1].a\n val r1 = Eb[N / 2].b\n\n val l2 = Ea[N / 2].a\n val r2 = Eb[N / 2 - 1].b\n\n debug{\"$l1:$r1 $l2:$r2\"}\n\n out.println(r1 + r2 - (l1 + l2) + 1)\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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 // なんか本番でエラーでる\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 * 勝手にimport消されるのを防ぎたい\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}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "sample_input": "2\n1 2\n2 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02661", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2902, "cpu_time_ms": 1100, "memory_kb": 70696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s244898406", "group_id": "codeNet:p02663", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val H1 = ni()\n val M1 = ni()\n val H2 = ni()\n val M2 = ni()\n val K = ni()\n val r = H2 * 60 + M2 - K\n val l = H1 * 60 + M1\n val ans = max(0, r - l)\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 // なんか本番でエラーでる\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 * 勝手にimport消されるのを防ぎたい\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "language": "Kotlin", "metadata": {"date": 1590887837, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02663.html", "problem_id": "p02663", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02663/input.txt", "sample_output_relpath": "derived/input_output/data/p02663/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02663/Kotlin/s244898406.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244898406", "user_id": "u460609472"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.max\nimport kotlin.math.min\n\nval MOD = 1_000_000_007L\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val H1 = ni()\n val M1 = ni()\n val H2 = ni()\n val M2 = ni()\n val K = ni()\n val r = H2 * 60 + M2 - K\n val l = H1 * 60 + M1\n val ans = max(0, r - l)\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 // なんか本番でエラーでる\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 * 勝手にimport消されるのを防ぎたい\n */\n private fun hoge() {\n min(1, 2)\n max(1, 2)\n abs(-10)\n }\n}\n\nfun main() {\n val out = java.io.PrintWriter(System.out)\n Solver(System.`in`, out).solve()\n out.flush()\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "sample_input": "10 0 15 0 30\n"}, "reference_outputs": ["270\n"], "source_document_id": "p02663", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2560, "cpu_time_ms": 74, "memory_kb": 34660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s392415448", "group_id": "codeNet:p02664", "input_text": "/** B */\nfun main(args: Array) {\n\n var t = readLine()!!\n\n /* TLE\n // 評価パターンをリスト化\n var evalTargetStrings = mutableListOf()\n evalTargetStrings.add(t)\n for (i in t.indices) {\n if (t[i] == '?') {\n evalTargetStrings = getEvalStrings(evalTargetStrings, i)\n }\n }\n\n // 指数の算出\n var score = 0\n var outputString = t\n for (evalTargetString in evalTargetStrings) {\n val tempScore = evalScore(evalTargetString)\n if (score < tempScore) {\n score = tempScore\n outputString = evalTargetString\n }\n }\n */\n\n var score = 0\n var evalTargetString = t\n\n // 評価パターンをリスト化\n var evalTargetStrings = mutableListOf()\n evalTargetStrings.add(t)\n for (i in t.indices) {\n if (t[i] == '?') {\n val evalTargetStringsNew = getEvalStrings(evalTargetStrings, i)\n\n for (evalTargetStringNew in evalTargetStringsNew) {\n val tempScore = evalScore(evalTargetStringNew)\n if (score < tempScore) {\n score = tempScore\n evalTargetString = evalTargetStringNew\n evalTargetStrings = mutableListOf(evalTargetString)\n }\n }\n }\n }\n\n println(evalTargetString)\n}\n\nprivate fun getEvalStrings(evalTargetStrings: MutableList, i: Int): MutableList {\n val evalStringsNew = mutableListOf()\n for (evalTargetString in evalTargetStrings) {\n val tempT1 = evalTargetString.replaceRange(i, i + 1, \"P\")\n val tempT2 = evalTargetString.replaceRange(i, i + 1, \"D\")\n evalStringsNew.add(tempT1)\n evalStringsNew.add(tempT2)\n }\n return evalStringsNew\n}\n\nprivate fun evalScore(s: String): Int {\n var score = 0\n var beforeChar = 'X'\n for (i in s.indices) {\n if (s[i] == 'D') {\n score++\n if (beforeChar == 'P') {\n score++\n }\n }\n beforeChar = s[i]\n }\n\n return score\n}", "language": "Kotlin", "metadata": {"date": 1590891402, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/Kotlin/s392415448.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s392415448", "user_id": "u621958170"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "/** B */\nfun main(args: Array) {\n\n var t = readLine()!!\n\n /* TLE\n // 評価パターンをリスト化\n var evalTargetStrings = mutableListOf()\n evalTargetStrings.add(t)\n for (i in t.indices) {\n if (t[i] == '?') {\n evalTargetStrings = getEvalStrings(evalTargetStrings, i)\n }\n }\n\n // 指数の算出\n var score = 0\n var outputString = t\n for (evalTargetString in evalTargetStrings) {\n val tempScore = evalScore(evalTargetString)\n if (score < tempScore) {\n score = tempScore\n outputString = evalTargetString\n }\n }\n */\n\n var score = 0\n var evalTargetString = t\n\n // 評価パターンをリスト化\n var evalTargetStrings = mutableListOf()\n evalTargetStrings.add(t)\n for (i in t.indices) {\n if (t[i] == '?') {\n val evalTargetStringsNew = getEvalStrings(evalTargetStrings, i)\n\n for (evalTargetStringNew in evalTargetStringsNew) {\n val tempScore = evalScore(evalTargetStringNew)\n if (score < tempScore) {\n score = tempScore\n evalTargetString = evalTargetStringNew\n evalTargetStrings = mutableListOf(evalTargetString)\n }\n }\n }\n }\n\n println(evalTargetString)\n}\n\nprivate fun getEvalStrings(evalTargetStrings: MutableList, i: Int): MutableList {\n val evalStringsNew = mutableListOf()\n for (evalTargetString in evalTargetStrings) {\n val tempT1 = evalTargetString.replaceRange(i, i + 1, \"P\")\n val tempT2 = evalTargetString.replaceRange(i, i + 1, \"D\")\n evalStringsNew.add(tempT1)\n evalStringsNew.add(tempT2)\n }\n return evalStringsNew\n}\n\nprivate fun evalScore(s: String): Int {\n var score = 0\n var beforeChar = 'X'\n for (i in s.indices) {\n if (s[i] == 'D') {\n score++\n if (beforeChar == 'P') {\n score++\n }\n }\n beforeChar = s[i]\n }\n\n return score\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2088, "cpu_time_ms": 2208, "memory_kb": 59272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s857381730", "group_id": "codeNet:p02664", "input_text": "fun main(args: Array) {\n val t = readLine()!!\n\n println(t.replace(\"?\", \"D\"))\n}", "language": "Kotlin", "metadata": {"date": 1590887326, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/Kotlin/s857381730.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s857381730", "user_id": "u620053468"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "fun main(args: Array) {\n val t = readLine()!!\n\n println(t.replace(\"?\", \"D\"))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 92, "cpu_time_ms": 376, "memory_kb": 58332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s508618174", "group_id": "codeNet:p02669", "input_text": "\n\nimport java.util.*\nimport kotlin.math.min\n\nfun main() {\n\n val coins = arrayOf(2L,3L,5L) //61, 39, 27\n\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n\n repeat(t) {\n val n = sc.nextLong()\n val costs = LongArray(3)\n costs[0] = sc.nextLong()\n costs[1] = sc.nextLong()\n costs[2] = sc.nextLong()\n\n val d = sc.nextLong()\n val cache = HashMap()\n\n fun bestCost(v:Long, c:Int, p : Long, r:Long): Long {\n if(p == 0L){\n return Long.MAX_VALUE\n }\n val remainder = r * d\n val cost = costs[c] + remainder\n val diff = v - p\n val costD = diff * d\n if(costD < 0)\n return cost\n return min(costD, cost)\n }\n\n fun solve(remain:Long): Long {\n if(remain == 0L)\n return 0L\n if(remain == 1L)\n return d\n if(cache.contains(remain)) {\n return cache[remain]!!\n }\n var best = Long.MAX_VALUE\n for(i in coins.indices) {\n val c = coins[i]\n val p = remain / c\n val r = remain % c\n val up = p + 1L\n val ur = c - r\n best = min(best, bestCost(remain, i, p, r) + solve(p))\n if(ur == c) {\n continue\n }\n best = min(best, bestCost(remain, i, up, ur) + solve(up))\n }\n cache[remain] = best\n return best\n }\n println(solve(n))\n\n\n }\n\n\n}", "language": "Kotlin", "metadata": {"date": 1590300489, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02669.html", "problem_id": "p02669", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02669/input.txt", "sample_output_relpath": "derived/input_output/data/p02669/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02669/Kotlin/s508618174.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s508618174", "user_id": "u682597394"}, "prompt_components": {"gold_output": "20\n19\n26\n3821859835\n23441258666\n", "input_to_evaluate": "\n\nimport java.util.*\nimport kotlin.math.min\n\nfun main() {\n\n val coins = arrayOf(2L,3L,5L) //61, 39, 27\n\n val sc = Scanner(System.`in`)\n val t = sc.nextInt()\n\n repeat(t) {\n val n = sc.nextLong()\n val costs = LongArray(3)\n costs[0] = sc.nextLong()\n costs[1] = sc.nextLong()\n costs[2] = sc.nextLong()\n\n val d = sc.nextLong()\n val cache = HashMap()\n\n fun bestCost(v:Long, c:Int, p : Long, r:Long): Long {\n if(p == 0L){\n return Long.MAX_VALUE\n }\n val remainder = r * d\n val cost = costs[c] + remainder\n val diff = v - p\n val costD = diff * d\n if(costD < 0)\n return cost\n return min(costD, cost)\n }\n\n fun solve(remain:Long): Long {\n if(remain == 0L)\n return 0L\n if(remain == 1L)\n return d\n if(cache.contains(remain)) {\n return cache[remain]!!\n }\n var best = Long.MAX_VALUE\n for(i in coins.indices) {\n val c = coins[i]\n val p = remain / c\n val r = remain % c\n val up = p + 1L\n val ur = c - r\n best = min(best, bestCost(remain, i, p, r) + solve(p))\n if(ur == c) {\n continue\n }\n best = min(best, bestCost(remain, i, up, ur) + solve(up))\n }\n cache[remain] = best\n return best\n }\n println(solve(n))\n\n\n }\n\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "sample_input": "5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n"}, "reference_outputs": ["20\n19\n26\n3821859835\n23441258666\n"], "source_document_id": "p02669", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1623, "cpu_time_ms": 277, "memory_kb": 65732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s801473199", "group_id": "codeNet:p02670", "input_text": "fun main() {\n\tval n = readInt()\n\tval p = readInts().map { it - 1 }\n\tval dist = List(n) { x -> IntArray(n) { y -> sequenceOf(x, y, n - 1 - x, n - 1 - y).min()!! + 1 } }\n\tval on = List(n) { x -> BooleanArray(n) { true } }\n\tvar ans = 0\n\tfor (r in p) {\n\t\tval rx = r / n\n\t\tval ry = r % n\n\t\tans += dist[rx][ry] - 1\n\t\ton[rx][ry] = false\n\t\tdist[rx][ry]--\n\t\tval stack = mutableListOf(rx to ry)\n\t\twhile (stack.isNotEmpty()) {\n\t\t\tval (x, y) = stack.pop()\n\t\t\tval distHere = dist[x][y]\n\t\t\tfor (d in DX.indices) {\n\t\t\t\tval xx = x + DX[d]\n\t\t\t\tval yy = y + DY[d]\n\t\t\t\tval onNei = on.getOrNull(xx)?.getOrNull(yy) ?: continue\n\t\t\t\tval distNei = dist[xx][yy]\n\t\t\t\tval distNew = distHere + if (onNei) 1 else 0\n\t\t\t\tif (distNew < distNei) {\n\t\t\t\t\tdist[xx][yy]--\n\t\t\t\t\tstack.add(xx to yy)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintln(ans)\n}\n\nval DX = intArrayOf(1, 0, -1, 0)\nval DY = intArrayOf(0, 1, 0, -1)\n\nprivate fun MutableList.pop() = removeAt(lastIndex)\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1590284272, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02670.html", "problem_id": "p02670", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02670/input.txt", "sample_output_relpath": "derived/input_output/data/p02670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02670/Kotlin/s801473199.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s801473199", "user_id": "u932183990"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main() {\n\tval n = readInt()\n\tval p = readInts().map { it - 1 }\n\tval dist = List(n) { x -> IntArray(n) { y -> sequenceOf(x, y, n - 1 - x, n - 1 - y).min()!! + 1 } }\n\tval on = List(n) { x -> BooleanArray(n) { true } }\n\tvar ans = 0\n\tfor (r in p) {\n\t\tval rx = r / n\n\t\tval ry = r % n\n\t\tans += dist[rx][ry] - 1\n\t\ton[rx][ry] = false\n\t\tdist[rx][ry]--\n\t\tval stack = mutableListOf(rx to ry)\n\t\twhile (stack.isNotEmpty()) {\n\t\t\tval (x, y) = stack.pop()\n\t\t\tval distHere = dist[x][y]\n\t\t\tfor (d in DX.indices) {\n\t\t\t\tval xx = x + DX[d]\n\t\t\t\tval yy = y + DY[d]\n\t\t\t\tval onNei = on.getOrNull(xx)?.getOrNull(yy) ?: continue\n\t\t\t\tval distNei = dist[xx][yy]\n\t\t\t\tval distNew = distHere + if (onNei) 1 else 0\n\t\t\t\tif (distNew < distNei) {\n\t\t\t\t\tdist[xx][yy]--\n\t\t\t\t\tstack.add(xx to yy)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintln(ans)\n}\n\nval DX = intArrayOf(1, 0, -1, 0)\nval DY = intArrayOf(0, 1, 0, -1)\n\nprivate fun MutableList.pop() = removeAt(lastIndex)\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "sample_input": "3\n1 3 7 9 5 4 8 6 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02670", "source_text": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1104, "cpu_time_ms": 2208, "memory_kb": 102500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s774665676", "group_id": "codeNet:p02675", "input_text": "fun main() {\n val n=readLine()!!.toInt()\n println(when(n%10){\n 2,4,5,7,9->\"hon\"\n 0,1,6,8->\"pon\"\n else->\"bon\"\n })\n}", "language": "Kotlin", "metadata": {"date": 1589868412, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02675/input.txt", "sample_output_relpath": "derived/input_output/data/p02675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02675/Kotlin/s774665676.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s774665676", "user_id": "u670180528"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "fun main() {\n val n=readLine()!!.toInt()\n println(when(n%10){\n 2,4,5,7,9->\"hon\"\n 0,1,6,8->\"pon\"\n else->\"bon\"\n })\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "sample_input": "16\n"}, "reference_outputs": ["pon\n"], "source_document_id": "p02675", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 80, "memory_kb": 34408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s545310040", "group_id": "codeNet:p02675", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval n = readInt()\n\tval ans = when(n % 10) {\n\t\t2, 4, 5, 7, 9 -> { \"hon\" }\n\t\t0, 1, 6, 8 -> { \"pon\" }\n\t\telse -> \"bon\" \n\t}\n\tprintln(ans)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1589763759, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02675/input.txt", "sample_output_relpath": "derived/input_output/data/p02675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02675/Kotlin/s545310040.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545310040", "user_id": "u026686258"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval n = readInt()\n\tval ans = when(n % 10) {\n\t\t2, 4, 5, 7, 9 -> { \"hon\" }\n\t\t0, 1, 6, 8 -> { \"pon\" }\n\t\telse -> \"bon\" \n\t}\n\tprintln(ans)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 0L -> 1L\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "sample_input": "16\n"}, "reference_outputs": ["pon\n"], "source_document_id": "p02675", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5284, "cpu_time_ms": 85, "memory_kb": 34604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s581886758", "group_id": "codeNet:p02675", "input_text": "fun main() = Thread(null, ::abc168a, \"\", 128 * 1024 * 1024).start()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc168a() {\n val n = readLine()!!.toInt()\n\n val answer = when (n.toString().last().toString().toInt()) {\n 2, 4, 5, 7, 9 -> \"hon\"\n 0, 1, 6, 8 -> \"pon\"\n else -> \"bon\"\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1589763736, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02675/input.txt", "sample_output_relpath": "derived/input_output/data/p02675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02675/Kotlin/s581886758.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s581886758", "user_id": "u139478771"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "fun main() = Thread(null, ::abc168a, \"\", 128 * 1024 * 1024).start()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc168a() {\n val n = readLine()!!.toInt()\n\n val answer = when (n.toString().last().toString().toInt()) {\n 2, 4, 5, 7, 9 -> \"hon\"\n 0, 1, 6, 8 -> \"pon\"\n else -> \"bon\"\n }\n\n println(answer)\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "sample_input": "16\n"}, "reference_outputs": ["pon\n"], "source_document_id": "p02675", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\n\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in the phrase \"N 本\" for a positive integer N not exceeding 999 is as follows:\n\nhon when the digit in the one's place of N is 2, 4, 5, 7, or 9;\n\npon when the digit in the one's place of N is 0, 1, 6 or 8;\n\nbon when the digit in the one's place of N is 3.\n\nGiven N, print the pronunciation of \"本\" in the phrase \"N 本\".\n\nConstraints\n\nN is a positive integer not exceeding 999.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n16\n\nSample Output 1\n\npon\n\nThe digit in the one's place of 16 is 6, so the \"本\" in \"16 本\" is pronounced pon.\n\nSample Input 2\n\n2\n\nSample Output 2\n\nhon\n\nSample Input 3\n\n183\n\nSample Output 3\n\nbon", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 331, "cpu_time_ms": 103, "memory_kb": 36040}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s652942797", "group_id": "codeNet:p02676", "input_text": "fun main(args: Array) {\n val k = readLine()!!.toInt()\n val s = readLine()!!\n if (s.length > k) {\n print(s.substring(0, k) + \"...\")\n } else {\n print(s)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1590260671, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/Kotlin/s652942797.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s652942797", "user_id": "u992480745"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "fun main(args: Array) {\n val k = readLine()!!.toInt()\n val s = readLine()!!\n if (s.length > k) {\n print(s.substring(0, k) + \"...\")\n } else {\n print(s)\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 87, "memory_kb": 34468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s516178410", "group_id": "codeNet:p02676", "input_text": "fun main(args: Array) {\n val k = readLine()?.toInt()?:0\n val s = readLine()!!\n if (s.length <= k) {\n println(s)\n } else {\n val sub = s.substring(0, k)\n println(\"${sub}...\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1589765005, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/Kotlin/s516178410.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s516178410", "user_id": "u952914882"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "fun main(args: Array) {\n val k = readLine()?.toInt()?:0\n val s = readLine()!!\n if (s.length <= k) {\n println(s)\n } else {\n val sub = s.substring(0, k)\n println(\"${sub}...\")\n }\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 82, "memory_kb": 34484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s727130184", "group_id": "codeNet:p02676", "input_text": "fun main() {\n val k = readLine()!!.toInt()\n val s = readLine()!!\n println(if (s.length <= k) s else s.slice(0 until k) + \"...\")\n}\n", "language": "Kotlin", "metadata": {"date": 1589763845, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/Kotlin/s727130184.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s727130184", "user_id": "u863309603"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "fun main() {\n val k = readLine()!!.toInt()\n val s = readLine()!!\n println(if (s.length <= k) s else s.slice(0 until k) + \"...\")\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 139, "cpu_time_ms": 97, "memory_kb": 35972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s978145802", "group_id": "codeNet:p02677", "input_text": "fun main(args: Array) {\n val (a, b, h, m) = readLine()!!.split(' ').map(String::toLong)\n val minute = h * 60 + m\n val hDeg = minute.toDouble() / 720.0 * 2 * Math.PI\n val mDeg = m / 60.0 * 2 * Math.PI\n\n val ax = a * Math.sin(hDeg)\n val ay = a * Math.cos(hDeg)\n val bx = b * Math.sin(mDeg)\n val by = b * Math.cos(mDeg)\n val xDiff = Math.abs(ax - bx)\n val yDiff = Math.abs(ay - by)\n val dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff)\n\n println(dist)\n}\n", "language": "Kotlin", "metadata": {"date": 1598142350, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Kotlin/s978145802.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s978145802", "user_id": "u099066216"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, h, m) = readLine()!!.split(' ').map(String::toLong)\n val minute = h * 60 + m\n val hDeg = minute.toDouble() / 720.0 * 2 * Math.PI\n val mDeg = m / 60.0 * 2 * Math.PI\n\n val ax = a * Math.sin(hDeg)\n val ay = a * Math.cos(hDeg)\n val bx = b * Math.sin(mDeg)\n val by = b * Math.cos(mDeg)\n val xDiff = Math.abs(ax - bx)\n val yDiff = Math.abs(ay - by)\n val dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff)\n\n println(dist)\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 494, "cpu_time_ms": 117, "memory_kb": 36592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s235376220", "group_id": "codeNet:p02677", "input_text": "import kotlin.math.*\nfun main(args: Array) {\n val n = readLine()!!.split(' ').map(String::toDouble)\n var angle = 0.0\n if(Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0) > PI){\n angle = 2.0*PI - Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)\n }else{\n angle = Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)\n }\n println(Math.sqrt(n[0]*n[0] + n[1]*n[1] - 2*n[0]*n[1]*cos(angle)))\n //val s = cos(PI)\n //println(s)\n}", "language": "Kotlin", "metadata": {"date": 1590045180, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Kotlin/s235376220.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235376220", "user_id": "u759348945"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import kotlin.math.*\nfun main(args: Array) {\n val n = readLine()!!.split(' ').map(String::toDouble)\n var angle = 0.0\n if(Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0) > PI){\n angle = 2.0*PI - Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)\n }else{\n angle = Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)\n }\n println(Math.sqrt(n[0]*n[0] + n[1]*n[1] - 2*n[0]*n[1]*cos(angle)))\n //val s = cos(PI)\n //println(s)\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 413, "cpu_time_ms": 100, "memory_kb": 36648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s925717034", "group_id": "codeNet:p02677", "input_text": "import kotlin.math.pow\nimport kotlin.math.sqrt\n\nfun main() {\n val (a, b, h, m) = readLine()!!.split(' ').map { it.toDouble() }\n val d1 = 30 * h + 0.5 * m\n val d2 = 6 * m\n val d = if (d1 > d2) d1 - d2 else d2 - d1\n val r = d * Math.PI / 180\n val c = a.pow(2) + b.pow(2) - Math.cos(r) * 2 * a * b\n println(sqrt(c))\n}\n", "language": "Kotlin", "metadata": {"date": 1589764746, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Kotlin/s925717034.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s925717034", "user_id": "u863309603"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import kotlin.math.pow\nimport kotlin.math.sqrt\n\nfun main() {\n val (a, b, h, m) = readLine()!!.split(' ').map { it.toDouble() }\n val d1 = 30 * h + 0.5 * m\n val d2 = 6 * m\n val d = if (d1 > d2) d1 - d2 else d2 - d1\n val r = d * Math.PI / 180\n val c = a.pow(2) + b.pow(2) - Math.cos(r) * 2 * a * b\n println(sqrt(c))\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 336, "cpu_time_ms": 98, "memory_kb": 36664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s894201674", "group_id": "codeNet:p02677", "input_text": "import kotlin.math.abs\n\nfun main(args: Array){\n\n val (a,b,h,m) = readLine()!!.split(\" \").map { it.toInt() }\n\n val mm = Math.PI * 2 / 60.0 * m\n val hh = Math.PI * 2 * h / 12.0 + Math.PI * 2 / 12.0 * m / 60.0\n\n val c2 = a * a + b * b -2 * a * b * Math.cos(abs(mm - hh))\n print(Math.sqrt(abs(c2)))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1589764684, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Kotlin/s894201674.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894201674", "user_id": "u049930986"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import kotlin.math.abs\n\nfun main(args: Array){\n\n val (a,b,h,m) = readLine()!!.split(\" \").map { it.toInt() }\n\n val mm = Math.PI * 2 / 60.0 * m\n val hh = Math.PI * 2 * h / 12.0 + Math.PI * 2 / 12.0 * m / 60.0\n\n val c2 = a * a + b * b -2 * a * b * Math.cos(abs(mm - hh))\n print(Math.sqrt(abs(c2)))\n}\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 101, "memory_kb": 36588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s465460741", "group_id": "codeNet:p02678", "input_text": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val n = sc.nextInt()\n val m = sc.nextInt()\n \n val rinsetu = Array(n) { mutableListOf() }\n val result = IntArray(n) { -1 }\n\n repeat(m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n rinsetu[a].add(b)\n rinsetu[b].add(a)\n }\n\n val queue = ArrayDeque()\n rinsetu[0].forEach {\n queue.add(intArrayOf(0, it))\n }\n result[0] = 0\n\n while (queue.isNotEmpty()) {\n val (from, to) = queue.remove()\n if (result[to] >= 0) continue\n result[to] = from + 1\n rinsetu[to].forEach {\n if (result[it] < 0) queue.add(intArrayOf(to, it))\n }\n }\n\n if (result.any { it < 0 }) {\n out.println(\"No\")\n } else {\n out.println(\"Yes\")\n for (i in 1 until n) {\n out.println(result[i])\n }\n }\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(2048)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n private fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object : CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private inline fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private inline fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n\n class BitSet(capacity: Int) {\n val bitset = java.util.BitSet(capacity)\n\n val cardinality: Int\n get() = bitset.cardinality()\n\n override fun equals(other: Any?) = (other as? BitSet)?.let { it.bitset == bitset } ?: false\n\n operator fun set(n: Int, f: Boolean) {\n if (f) {\n bitset.set(n)\n } else {\n bitset.clear(n)\n }\n }\n\n operator fun get(n: Int) = bitset[n]\n\n fun trueIterator(startIndex: Int = 0) = object: IntIterator() {\n var nextPos = bitset.nextSetBit(startIndex)\n\n override fun hasNext() = nextPos in 0 until Int.MAX_VALUE\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.nextSetBit(nextPos + 1)\n return value\n }\n }\n\n fun falseIterator(startIndex: Int = 0) = object: IntIterator() {\n var nextPos = bitset.nextClearBit(startIndex)\n\n override fun hasNext() = nextPos in 0 until Int.MAX_VALUE\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.nextClearBit(nextPos + 1)\n return value\n }\n }\n\n fun trueIteratorReversed(startIndex: Int = bitset.length() - 1) = object: IntIterator() {\n var nextPos = bitset.previousSetBit(startIndex)\n\n override fun hasNext() = nextPos >= 0\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.previousSetBit(nextPos - 1)\n return value\n }\n }\n\n fun falseIteratorReversed(startIndex: Int = bitset.length() - 1) = object: IntIterator() {\n var nextPos = bitset.previousClearBit(startIndex)\n\n override fun hasNext() = nextPos >= 0\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.previousClearBit(nextPos - 1)\n return value\n }\n }\n\n fun and(other: BitSet) {\n bitset.and(other.bitset)\n }\n\n fun or(other: BitSet) {\n bitset.or(other.bitset)\n }\n\n fun xor(other: BitSet) {\n bitset.xor(other.bitset)\n }\n\n fun andNot(other: BitSet) {\n bitset.andNot(other.bitset)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589768721, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02678/input.txt", "sample_output_relpath": "derived/input_output/data/p02678/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02678/Kotlin/s465460741.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465460741", "user_id": "u996672406"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val n = sc.nextInt()\n val m = sc.nextInt()\n \n val rinsetu = Array(n) { mutableListOf() }\n val result = IntArray(n) { -1 }\n\n repeat(m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n rinsetu[a].add(b)\n rinsetu[b].add(a)\n }\n\n val queue = ArrayDeque()\n rinsetu[0].forEach {\n queue.add(intArrayOf(0, it))\n }\n result[0] = 0\n\n while (queue.isNotEmpty()) {\n val (from, to) = queue.remove()\n if (result[to] >= 0) continue\n result[to] = from + 1\n rinsetu[to].forEach {\n if (result[it] < 0) queue.add(intArrayOf(to, it))\n }\n }\n\n if (result.any { it < 0 }) {\n out.println(\"No\")\n } else {\n out.println(\"Yes\")\n for (i in 1 until n) {\n out.println(result[i])\n }\n }\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(2048)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n private fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object : CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private inline fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private inline fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n\n class BitSet(capacity: Int) {\n val bitset = java.util.BitSet(capacity)\n\n val cardinality: Int\n get() = bitset.cardinality()\n\n override fun equals(other: Any?) = (other as? BitSet)?.let { it.bitset == bitset } ?: false\n\n operator fun set(n: Int, f: Boolean) {\n if (f) {\n bitset.set(n)\n } else {\n bitset.clear(n)\n }\n }\n\n operator fun get(n: Int) = bitset[n]\n\n fun trueIterator(startIndex: Int = 0) = object: IntIterator() {\n var nextPos = bitset.nextSetBit(startIndex)\n\n override fun hasNext() = nextPos in 0 until Int.MAX_VALUE\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.nextSetBit(nextPos + 1)\n return value\n }\n }\n\n fun falseIterator(startIndex: Int = 0) = object: IntIterator() {\n var nextPos = bitset.nextClearBit(startIndex)\n\n override fun hasNext() = nextPos in 0 until Int.MAX_VALUE\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.nextClearBit(nextPos + 1)\n return value\n }\n }\n\n fun trueIteratorReversed(startIndex: Int = bitset.length() - 1) = object: IntIterator() {\n var nextPos = bitset.previousSetBit(startIndex)\n\n override fun hasNext() = nextPos >= 0\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.previousSetBit(nextPos - 1)\n return value\n }\n }\n\n fun falseIteratorReversed(startIndex: Int = bitset.length() - 1) = object: IntIterator() {\n var nextPos = bitset.previousClearBit(startIndex)\n\n override fun hasNext() = nextPos >= 0\n\n override fun nextInt(): Int {\n val value = nextPos\n nextPos = bitset.previousClearBit(nextPos - 1)\n return value\n }\n }\n\n fun and(other: BitSet) {\n bitset.and(other.bitset)\n }\n\n fun or(other: BitSet) {\n bitset.or(other.bitset)\n }\n\n fun xor(other: BitSet) {\n bitset.xor(other.bitset)\n }\n\n fun andNot(other: BitSet) {\n bitset.andNot(other.bitset)\n }\n }\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 2\n"}, "reference_outputs": ["Yes\n1\n2\n2\n"], "source_document_id": "p02678", "source_text": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7401, "cpu_time_ms": 423, "memory_kb": 70200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s118703682", "group_id": "codeNet:p02679", "input_text": "package abc168\n\nimport java.io.*\nimport java.math.*\nimport java.util.*\nimport kotlin.math.*\n\nvar reader: BufferedReader = System.`in`.bufferedReader()\nvar writer: PrintWriter = PrintWriter(System.`out`)\n\nfun next() = reader.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextStrings() = next().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\nfun nextDoubles() = nextStrings().map { it.toDouble() }\n\nfun put(v: Any?) = writer.print(v)\nfun puts() = writer.println()\nfun puts(v: Any?) = writer.println(v)\n\nvar debug = false\nfun dprintln(v: Any?) {\n if (debug) println(v)\n}\nfun dprintln() {\n if (debug) println()\n}\n\nclass ModInt(\n val value: Long\n) {\n private val POW = mutableMapOf()\n\n operator fun plus(rhs: ModInt): ModInt {\n return ModInt((value + rhs.value) % M)\n }\n operator fun minus(rhs: ModInt): ModInt {\n return ModInt((value - rhs.value + M) % M)\n }\n operator fun times(rhs: ModInt): ModInt {\n return ModInt((value * rhs.value) % M)\n }\n operator fun div(rhs: ModInt): ModInt {\n return ModInt(value * inv(rhs.value) % M)\n }\n private fun inv(v: Long): Long {\n return INV.computeIfAbsent(v) {\n M - (((M / v) * inv(M % v)) % M)\n }\n }\n fun pow(v: Int): ModInt {\n return POW.computeIfAbsent(v) {\n var result = 1L\n var x = v\n var vv = value\n while (x != 0) {\n if ((x and 1) != 0) {\n result = (result * vv) % M\n }\n vv = (vv * vv) % M\n x = x ushr 1\n }\n ModInt(result)\n }\n }\n\n override fun toString(): String {\n return value.toString()\n }\n\n companion object {\n private const val M = 1000000007L\n\n private val INV = mutableMapOf().also {\n it[1] = 1\n }\n\n val ZERO = ModInt(0)\n val ONE = ModInt(1)\n }\n}\n\nfun test(case: Int, input: String, expected: String) {\n reader = input.trimIndent().reader().buffered()\n\n val stringWriter = StringWriter()\n writer = PrintWriter(stringWriter)\n\n solve()\n writer.flush()\n\n val actual = stringWriter.toString()\n\n println(\"[test $case]\")\n if (\"${expected}\" == actual) {\n println(\"OK\")\n } else {\n println(\"NG\")\n println()\n println(\"expected: \\\"${expected}\\\"\")\n println(\"actual: \\\"${actual}\\\"\")\n }\n println()\n}\n\nfun main(args: Array) {\n if ((args.size == 1) && (args[0] == \"test\")) {\n testAll()\n } else {\n solve()\n writer.flush()\n }\n}\n\n///////////////////////////////////////////////////////////\n\nfun testAll() {\n debug = true\n\n test(1,\n \"\"\"\n 3\n 1 2\n -1 1\n 2 -1\n \"\"\",\n \"5\"\n )\n test(2,\n \"\"\"\n 10\n 3 2\n 3 2\n -1 1\n 2 -1\n -3 -9\n -8 12\n 7 7\n 8 1\n 8 2\n 8 4\n \"\"\",\n \"479\"\n )\n}\n\nclass Fish(\n val a: BigInteger,\n val b: BigInteger\n) {\n val cos: Double\n var visited = false\n\n init {\n val aDouble = a.toDouble()\n val bDouble = b.toDouble()\n val c = (aDouble * aDouble) / (aDouble * aDouble + bDouble * bDouble)\n cos = if (aDouble > 0.0) {\n c\n } else {\n -c\n }\n }\n\n constructor(a: Long, b: Long): this(BigInteger.valueOf(a), BigInteger.valueOf(b))\n\n fun opposite(rhs: Fish): BigInteger {\n return ((a * rhs.a) + (b * rhs.b))\n }\n fun sameGroup(rhs: Fish): BigInteger {\n return (a * rhs.b) - (b * rhs.a)\n }\n\n override fun toString(): String {\n return \"($a, $b, $cos)\"\n }\n}\n\n// 0以上の最初の要素 (入力は降順)\nfun bsearch_upper(list: List): Int {\n var l = 0\n var u = list.size\n\n while (l < u) {\n val m = (l + u) / 2\n val mValue = list[m]\n\n if (mValue.cos <= -0.000001) {\n u = m\n } else {\n l = m + 1\n }\n }\n\n return u\n}\n\n// 0以下の最初の要素 (入力は昇順)\nfun bsearch_lower(list: List): Int {\n var l = 0\n var u = list.size\n\n while (l < u) {\n val m = (l + u) / 2\n val mValue = list[m]\n\n if (mValue.cos >= -0.000001) {\n u = m\n } else {\n l = m + 1\n }\n }\n\n return u\n}\n\nval TWO = ModInt(2)\n\nfun calculate(list: List, subList: List, listOppositeStart: Int, sublistOppositeStart: Int): ModInt {\n\n var result = ModInt.ONE\n\n var index = 0\n var subListIndex = 0\n var listOppsiteIndex = listOppositeStart\n var subListOppsiteIndex = sublistOppositeStart\n\n while (index < list.size) {\n val base = list[index]\n dprintln(\"check: [$index] $base\")\n ++index\n\n if (base.visited) {\n dprintln(\"skip(0)\")\n continue;\n }\n base.visited = true\n\n var numSameGroup = 1\n var numOpposite = 0\n\n while (index < list.size) {\n val rhs = list[index]\n dprintln(\"sg: [$index] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(1-0)\")\n break\n }\n\n val s = base.sameGroup(rhs)\n dprintln(\"-> $s\")\n if (s > BigInteger.ZERO) {\n break\n }\n if (s == BigInteger.ZERO) {\n dprintln(\"sameG\")\n rhs.visited = true\n ++numSameGroup\n }\n ++index\n }\n while (listOppsiteIndex < list.size) {\n val rhs = list[listOppsiteIndex]\n dprintln(\"op: [$listOppsiteIndex] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(1)\")\n ++listOppsiteIndex\n continue\n }\n\n val o = base.opposite(rhs)\n dprintln(\"-> $o\")\n\n if (o < BigInteger.ZERO) {\n break;\n }\n if (o == BigInteger.ZERO) {\n dprintln(\"opposite\")\n rhs.visited = true\n ++numOpposite\n }\n ++listOppsiteIndex\n }\n\n while (subListIndex < subList.size) {\n val rhs = subList[subListIndex]\n dprintln(\"sg2: [$subListIndex] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(2)\")\n ++subListIndex\n continue\n }\n\n val s = base.sameGroup(rhs)\n dprintln(\"-> $s\")\n if (s < BigInteger.ZERO) {\n break\n }\n if (s == BigInteger.ZERO) {\n dprintln(\"sameG\")\n rhs.visited = true\n ++numSameGroup\n }\n ++subListIndex\n }\n\n while (subListOppsiteIndex < subList.size) {\n val rhs = subList[subListOppsiteIndex]\n dprintln(\"op2: [$subListOppsiteIndex] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(3)\")\n ++subListOppsiteIndex\n continue\n }\n\n val o = base.opposite(rhs)\n dprintln(\"-> $o\")\n\n if (o > BigInteger.ZERO) {\n break;\n }\n if (o == BigInteger.ZERO) {\n dprintln(\"opposite\")\n rhs.visited = true\n ++numOpposite\n }\n ++subListOppsiteIndex\n }\n\n dprintln(\"(2^${numOpposite} - 1) + (2^${numSameGroup} - 1) + 1 = ${(TWO.pow(numOpposite) - ModInt.ONE) + (TWO.pow(numSameGroup) - ModInt.ONE) + ModInt.ONE}\")\n dprintln()\n result *= (TWO.pow(numOpposite) - ModInt.ONE) +\n (TWO.pow(numSameGroup) - ModInt.ONE) + ModInt.ONE\n }\n\n return result\n}\n\nfun solve() {\n\n val N = nextInt()\n var upper = mutableListOf()\n val lower = mutableListOf()\n\n repeat(N) {\n val (a, b) = nextLongs()\n\n if ((b > 0L) || ((b == 0L) && (a >= 0L))) {\n upper.add(Fish(a, b))\n } else {\n lower.add(Fish(a, b))\n }\n }\n\n upper.sortBy { -it.cos }\n lower.sortBy { it.cos }\n\n val upperOppositeIndexStart = bsearch_upper(upper)\n val lowerOppositeIndexStart = bsearch_lower(lower)\n\n dprintln(upper)\n dprintln(upperOppositeIndexStart)\n dprintln(lower)\n dprintln(lowerOppositeIndexStart)\n dprintln()\n\n var result = ModInt.ONE\n\n result *= calculate(upper, lower, upperOppositeIndexStart, lowerOppositeIndexStart)\n result *= calculate(lower, upper, lowerOppositeIndexStart, upperOppositeIndexStart)\n\n put(result - ModInt.ONE)\n}\n", "language": "Kotlin", "metadata": {"date": 1590625431, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Kotlin/s118703682.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s118703682", "user_id": "u116752827"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "package abc168\n\nimport java.io.*\nimport java.math.*\nimport java.util.*\nimport kotlin.math.*\n\nvar reader: BufferedReader = System.`in`.bufferedReader()\nvar writer: PrintWriter = PrintWriter(System.`out`)\n\nfun next() = reader.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextStrings() = next().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\nfun nextDoubles() = nextStrings().map { it.toDouble() }\n\nfun put(v: Any?) = writer.print(v)\nfun puts() = writer.println()\nfun puts(v: Any?) = writer.println(v)\n\nvar debug = false\nfun dprintln(v: Any?) {\n if (debug) println(v)\n}\nfun dprintln() {\n if (debug) println()\n}\n\nclass ModInt(\n val value: Long\n) {\n private val POW = mutableMapOf()\n\n operator fun plus(rhs: ModInt): ModInt {\n return ModInt((value + rhs.value) % M)\n }\n operator fun minus(rhs: ModInt): ModInt {\n return ModInt((value - rhs.value + M) % M)\n }\n operator fun times(rhs: ModInt): ModInt {\n return ModInt((value * rhs.value) % M)\n }\n operator fun div(rhs: ModInt): ModInt {\n return ModInt(value * inv(rhs.value) % M)\n }\n private fun inv(v: Long): Long {\n return INV.computeIfAbsent(v) {\n M - (((M / v) * inv(M % v)) % M)\n }\n }\n fun pow(v: Int): ModInt {\n return POW.computeIfAbsent(v) {\n var result = 1L\n var x = v\n var vv = value\n while (x != 0) {\n if ((x and 1) != 0) {\n result = (result * vv) % M\n }\n vv = (vv * vv) % M\n x = x ushr 1\n }\n ModInt(result)\n }\n }\n\n override fun toString(): String {\n return value.toString()\n }\n\n companion object {\n private const val M = 1000000007L\n\n private val INV = mutableMapOf().also {\n it[1] = 1\n }\n\n val ZERO = ModInt(0)\n val ONE = ModInt(1)\n }\n}\n\nfun test(case: Int, input: String, expected: String) {\n reader = input.trimIndent().reader().buffered()\n\n val stringWriter = StringWriter()\n writer = PrintWriter(stringWriter)\n\n solve()\n writer.flush()\n\n val actual = stringWriter.toString()\n\n println(\"[test $case]\")\n if (\"${expected}\" == actual) {\n println(\"OK\")\n } else {\n println(\"NG\")\n println()\n println(\"expected: \\\"${expected}\\\"\")\n println(\"actual: \\\"${actual}\\\"\")\n }\n println()\n}\n\nfun main(args: Array) {\n if ((args.size == 1) && (args[0] == \"test\")) {\n testAll()\n } else {\n solve()\n writer.flush()\n }\n}\n\n///////////////////////////////////////////////////////////\n\nfun testAll() {\n debug = true\n\n test(1,\n \"\"\"\n 3\n 1 2\n -1 1\n 2 -1\n \"\"\",\n \"5\"\n )\n test(2,\n \"\"\"\n 10\n 3 2\n 3 2\n -1 1\n 2 -1\n -3 -9\n -8 12\n 7 7\n 8 1\n 8 2\n 8 4\n \"\"\",\n \"479\"\n )\n}\n\nclass Fish(\n val a: BigInteger,\n val b: BigInteger\n) {\n val cos: Double\n var visited = false\n\n init {\n val aDouble = a.toDouble()\n val bDouble = b.toDouble()\n val c = (aDouble * aDouble) / (aDouble * aDouble + bDouble * bDouble)\n cos = if (aDouble > 0.0) {\n c\n } else {\n -c\n }\n }\n\n constructor(a: Long, b: Long): this(BigInteger.valueOf(a), BigInteger.valueOf(b))\n\n fun opposite(rhs: Fish): BigInteger {\n return ((a * rhs.a) + (b * rhs.b))\n }\n fun sameGroup(rhs: Fish): BigInteger {\n return (a * rhs.b) - (b * rhs.a)\n }\n\n override fun toString(): String {\n return \"($a, $b, $cos)\"\n }\n}\n\n// 0以上の最初の要素 (入力は降順)\nfun bsearch_upper(list: List): Int {\n var l = 0\n var u = list.size\n\n while (l < u) {\n val m = (l + u) / 2\n val mValue = list[m]\n\n if (mValue.cos <= -0.000001) {\n u = m\n } else {\n l = m + 1\n }\n }\n\n return u\n}\n\n// 0以下の最初の要素 (入力は昇順)\nfun bsearch_lower(list: List): Int {\n var l = 0\n var u = list.size\n\n while (l < u) {\n val m = (l + u) / 2\n val mValue = list[m]\n\n if (mValue.cos >= -0.000001) {\n u = m\n } else {\n l = m + 1\n }\n }\n\n return u\n}\n\nval TWO = ModInt(2)\n\nfun calculate(list: List, subList: List, listOppositeStart: Int, sublistOppositeStart: Int): ModInt {\n\n var result = ModInt.ONE\n\n var index = 0\n var subListIndex = 0\n var listOppsiteIndex = listOppositeStart\n var subListOppsiteIndex = sublistOppositeStart\n\n while (index < list.size) {\n val base = list[index]\n dprintln(\"check: [$index] $base\")\n ++index\n\n if (base.visited) {\n dprintln(\"skip(0)\")\n continue;\n }\n base.visited = true\n\n var numSameGroup = 1\n var numOpposite = 0\n\n while (index < list.size) {\n val rhs = list[index]\n dprintln(\"sg: [$index] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(1-0)\")\n break\n }\n\n val s = base.sameGroup(rhs)\n dprintln(\"-> $s\")\n if (s > BigInteger.ZERO) {\n break\n }\n if (s == BigInteger.ZERO) {\n dprintln(\"sameG\")\n rhs.visited = true\n ++numSameGroup\n }\n ++index\n }\n while (listOppsiteIndex < list.size) {\n val rhs = list[listOppsiteIndex]\n dprintln(\"op: [$listOppsiteIndex] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(1)\")\n ++listOppsiteIndex\n continue\n }\n\n val o = base.opposite(rhs)\n dprintln(\"-> $o\")\n\n if (o < BigInteger.ZERO) {\n break;\n }\n if (o == BigInteger.ZERO) {\n dprintln(\"opposite\")\n rhs.visited = true\n ++numOpposite\n }\n ++listOppsiteIndex\n }\n\n while (subListIndex < subList.size) {\n val rhs = subList[subListIndex]\n dprintln(\"sg2: [$subListIndex] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(2)\")\n ++subListIndex\n continue\n }\n\n val s = base.sameGroup(rhs)\n dprintln(\"-> $s\")\n if (s < BigInteger.ZERO) {\n break\n }\n if (s == BigInteger.ZERO) {\n dprintln(\"sameG\")\n rhs.visited = true\n ++numSameGroup\n }\n ++subListIndex\n }\n\n while (subListOppsiteIndex < subList.size) {\n val rhs = subList[subListOppsiteIndex]\n dprintln(\"op2: [$subListOppsiteIndex] $rhs\")\n\n if (rhs.visited) {\n dprintln(\"skip(3)\")\n ++subListOppsiteIndex\n continue\n }\n\n val o = base.opposite(rhs)\n dprintln(\"-> $o\")\n\n if (o > BigInteger.ZERO) {\n break;\n }\n if (o == BigInteger.ZERO) {\n dprintln(\"opposite\")\n rhs.visited = true\n ++numOpposite\n }\n ++subListOppsiteIndex\n }\n\n dprintln(\"(2^${numOpposite} - 1) + (2^${numSameGroup} - 1) + 1 = ${(TWO.pow(numOpposite) - ModInt.ONE) + (TWO.pow(numSameGroup) - ModInt.ONE) + ModInt.ONE}\")\n dprintln()\n result *= (TWO.pow(numOpposite) - ModInt.ONE) +\n (TWO.pow(numSameGroup) - ModInt.ONE) + ModInt.ONE\n }\n\n return result\n}\n\nfun solve() {\n\n val N = nextInt()\n var upper = mutableListOf()\n val lower = mutableListOf()\n\n repeat(N) {\n val (a, b) = nextLongs()\n\n if ((b > 0L) || ((b == 0L) && (a >= 0L))) {\n upper.add(Fish(a, b))\n } else {\n lower.add(Fish(a, b))\n }\n }\n\n upper.sortBy { -it.cos }\n lower.sortBy { it.cos }\n\n val upperOppositeIndexStart = bsearch_upper(upper)\n val lowerOppositeIndexStart = bsearch_lower(lower)\n\n dprintln(upper)\n dprintln(upperOppositeIndexStart)\n dprintln(lower)\n dprintln(lowerOppositeIndexStart)\n dprintln()\n\n var result = ModInt.ONE\n\n result *= calculate(upper, lower, upperOppositeIndexStart, lowerOppositeIndexStart)\n result *= calculate(lower, upper, lowerOppositeIndexStart, upperOppositeIndexStart)\n\n put(result - ModInt.ONE)\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8776, "cpu_time_ms": 89, "memory_kb": 35236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s780940505", "group_id": "codeNet:p02679", "input_text": "import kotlin.math.pow\n\nval M = 1000000007L\n\nfun main() {\n val n = readLine()!!.toInt()\n var zeros = 0L\n val iwashiMap = mutableMapOf()\n repeat(n) {\n val (a, b) = readLine()!!.split(\" \")\n val aa = a.toLong()\n val bb = b.toLong()\n val f = fraction(aa, bb)\n if (f is Fraction.Zero) {\n zeros += 1\n } else {\n val v = iwashiMap.getOrDefault(f, 0)\n iwashiMap[f] = v + 1\n }\n }\n\n iwashiMap.keys.forEach { f ->\n val o = f.opposite()\n if (iwashiMap.containsKey(o)) f.hasOpposite = o\n }\n\n val resultMap = mutableMapOf, Long>()\n\n iwashiMap.forEach { (k, v) -> resultMap[setOf(k)] = pow2(v) }\n for (size in 1 until iwashiMap.keys.size) {\n val candidates = resultMap.filterKeys { k -> k.size == size }\n candidates.forEach { (k, v) ->\n val candidateOpposites = k.mapNotNullTo(mutableSetOf()) { it.hasOpposite }\n iwashiMap.keys.forEach inner@{ f ->\n if (candidateOpposites.contains(f)) return@inner\n if (k.contains(f)) return@inner\n resultMap[k + f] = v * pow2(iwashiMap.getValue(f)) % M\n }\n }\n }\n val index = resultMap.values.fold(0L) { b, a -> (a + b) % M }\n val result = (zeros + index) % M\n println(result)\n}\n\nfun pow2(n: Int): Long = (2.0.pow(n).toLong() - 1) % M\n\nsealed class Fraction {\n data class F(val m: Long, val n: Long) : Fraction() {\n override fun opposite(): Fraction = if (m > 0) F(-n, m) else F(n, -m)\n }\n\n object ZeroOne : Fraction() {\n override fun opposite(): Fraction = OneZero\n }\n\n object OneZero : Fraction() {\n override fun opposite(): Fraction = ZeroOne\n }\n\n object Zero : Fraction() {\n override fun opposite(): Fraction = Zero\n }\n\n abstract fun opposite(): Fraction\n var hasOpposite: Fraction? = null\n}\n\nfun fraction(m: Long, n: Long): Fraction {\n return when {\n m == 0L && n == 0L -> Fraction.Zero\n m == 0L -> Fraction.ZeroOne\n n == 0L -> Fraction.OneZero\n else -> {\n val a = gcd(m, n)\n Fraction.F(m / a, n / a)\n }\n }\n}\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n", "language": "Kotlin", "metadata": {"date": 1590507266, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Kotlin/s780940505.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s780940505", "user_id": "u153253722"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import kotlin.math.pow\n\nval M = 1000000007L\n\nfun main() {\n val n = readLine()!!.toInt()\n var zeros = 0L\n val iwashiMap = mutableMapOf()\n repeat(n) {\n val (a, b) = readLine()!!.split(\" \")\n val aa = a.toLong()\n val bb = b.toLong()\n val f = fraction(aa, bb)\n if (f is Fraction.Zero) {\n zeros += 1\n } else {\n val v = iwashiMap.getOrDefault(f, 0)\n iwashiMap[f] = v + 1\n }\n }\n\n iwashiMap.keys.forEach { f ->\n val o = f.opposite()\n if (iwashiMap.containsKey(o)) f.hasOpposite = o\n }\n\n val resultMap = mutableMapOf, Long>()\n\n iwashiMap.forEach { (k, v) -> resultMap[setOf(k)] = pow2(v) }\n for (size in 1 until iwashiMap.keys.size) {\n val candidates = resultMap.filterKeys { k -> k.size == size }\n candidates.forEach { (k, v) ->\n val candidateOpposites = k.mapNotNullTo(mutableSetOf()) { it.hasOpposite }\n iwashiMap.keys.forEach inner@{ f ->\n if (candidateOpposites.contains(f)) return@inner\n if (k.contains(f)) return@inner\n resultMap[k + f] = v * pow2(iwashiMap.getValue(f)) % M\n }\n }\n }\n val index = resultMap.values.fold(0L) { b, a -> (a + b) % M }\n val result = (zeros + index) % M\n println(result)\n}\n\nfun pow2(n: Int): Long = (2.0.pow(n).toLong() - 1) % M\n\nsealed class Fraction {\n data class F(val m: Long, val n: Long) : Fraction() {\n override fun opposite(): Fraction = if (m > 0) F(-n, m) else F(n, -m)\n }\n\n object ZeroOne : Fraction() {\n override fun opposite(): Fraction = OneZero\n }\n\n object OneZero : Fraction() {\n override fun opposite(): Fraction = ZeroOne\n }\n\n object Zero : Fraction() {\n override fun opposite(): Fraction = Zero\n }\n\n abstract fun opposite(): Fraction\n var hasOpposite: Fraction? = null\n}\n\nfun fraction(m: Long, n: Long): Fraction {\n return when {\n m == 0L && n == 0L -> Fraction.Zero\n m == 0L -> Fraction.ZeroOne\n n == 0L -> Fraction.OneZero\n else -> {\n val a = gcd(m, n)\n Fraction.F(m / a, n / a)\n }\n }\n}\n\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2296, "cpu_time_ms": 2213, "memory_kb": 302404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s886262887", "group_id": "codeNet:p02679", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val map = HashMap>()\n var zero = 0L\n repeat(N) {\n val (x, y) = readLine()!!.split(\" \").map(String::toLong)\n if (x == 0L && y == 0L) {\n zero++\n return@repeat\n }\n var v = V(x, y).gcd_normalized()\n if (y < 0 || (y == 0L && x < 0)) {\n v = v.rot180()\n }\n val rot = x <= 0\n if (rot) {\n v = v.rot270()\n }\n if (!map.contains(v)) map[v] = MutablePair(0L, 0L)\n if (rot) map[v]!!.g1++\n else map[v]!!.g2++\n }\n var ans = MInt(1)\n map.values.forEach { g ->\n var sum = MInt(1)\n sum += MInt(2).pow(g.g1) - 1\n sum += MInt(2).pow(g.g2) - 1\n ans *= sum\n }\n ans -= 1 // answer should select at lease 1 fish, so remove a patten that no fish selected\n ans += zero // fish(0,0) is only valid for a pattern in which only the fish is selected.\n println(ans)\n}\n\ndata class MutablePair(var g1: A, var g2: B)\n\ndata class V(val x: Long, val y: Long) {\n fun rot90() = V(-y, x)\n fun rot180() = V(-x, -y)\n fun rot270() = V(y, -x)\n fun gcd_normalized() = V(x / gcd(x, y), y / gcd(x, y))\n}\n\nfun gcd(a: Long, b: Long): Long {\n if (a < b) return gcd(b, a)\n if (b == 0L) return a\n return gcd(b, a % b)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a.v += b.v\n if (a.v >= MOD) a.v -= MOD\n return a\n }\n\n operator fun plus(b: Int) = plus(MInt(b))\n operator fun plus(b: Long) = plus(MInt(b))\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a.v -= b.v\n if (a.v < 0) a.v += MOD\n return a\n }\n\n operator fun minus(b: Int) = minus(MInt(b))\n operator fun minus(b: Long) = minus(MInt(b))\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a.v *= b.v\n a.v %= MOD\n return a\n }\n\n operator fun div(b: MInt): MInt {\n return MInt(v) * b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(N: Int) = pow(N.toLong())\n\n fun pow(N: Long): MInt {\n var ans = MInt(1)\n var a = this\n var n = N\n while (n > 0) {\n if (n.and(1) == 1L) {\n ans *= a\n }\n a *= a\n n = n.shr(1)\n }\n return ans\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}", "language": "Kotlin", "metadata": {"date": 1589955473, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Kotlin/s886262887.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s886262887", "user_id": "u860789370"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val map = HashMap>()\n var zero = 0L\n repeat(N) {\n val (x, y) = readLine()!!.split(\" \").map(String::toLong)\n if (x == 0L && y == 0L) {\n zero++\n return@repeat\n }\n var v = V(x, y).gcd_normalized()\n if (y < 0 || (y == 0L && x < 0)) {\n v = v.rot180()\n }\n val rot = x <= 0\n if (rot) {\n v = v.rot270()\n }\n if (!map.contains(v)) map[v] = MutablePair(0L, 0L)\n if (rot) map[v]!!.g1++\n else map[v]!!.g2++\n }\n var ans = MInt(1)\n map.values.forEach { g ->\n var sum = MInt(1)\n sum += MInt(2).pow(g.g1) - 1\n sum += MInt(2).pow(g.g2) - 1\n ans *= sum\n }\n ans -= 1 // answer should select at lease 1 fish, so remove a patten that no fish selected\n ans += zero // fish(0,0) is only valid for a pattern in which only the fish is selected.\n println(ans)\n}\n\ndata class MutablePair(var g1: A, var g2: B)\n\ndata class V(val x: Long, val y: Long) {\n fun rot90() = V(-y, x)\n fun rot180() = V(-x, -y)\n fun rot270() = V(y, -x)\n fun gcd_normalized() = V(x / gcd(x, y), y / gcd(x, y))\n}\n\nfun gcd(a: Long, b: Long): Long {\n if (a < b) return gcd(b, a)\n if (b == 0L) return a\n return gcd(b, a % b)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a.v += b.v\n if (a.v >= MOD) a.v -= MOD\n return a\n }\n\n operator fun plus(b: Int) = plus(MInt(b))\n operator fun plus(b: Long) = plus(MInt(b))\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a.v -= b.v\n if (a.v < 0) a.v += MOD\n return a\n }\n\n operator fun minus(b: Int) = minus(MInt(b))\n operator fun minus(b: Long) = minus(MInt(b))\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a.v *= b.v\n a.v %= MOD\n return a\n }\n\n operator fun div(b: MInt): MInt {\n return MInt(v) * b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(N: Int) = pow(N.toLong())\n\n fun pow(N: Long): MInt {\n var ans = MInt(1)\n var a = this\n var n = N\n while (n > 0) {\n if (n.and(1) == 1L) {\n ans *= a\n }\n a *= a\n n = n.shr(1)\n }\n return ans\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3044, "cpu_time_ms": 437, "memory_kb": 58484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s824126284", "group_id": "codeNet:p02680", "input_text": "//package abc168.F\n\nimport java.io.*\nimport java.math.*\nimport java.util.*\nimport kotlin.math.*\n\nvar reader: BufferedReader = System.`in`.bufferedReader()\nvar writer: PrintWriter = PrintWriter(System.`out`)\n\nfun next() = reader.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextStrings() = next().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\nfun nextDoubles() = nextStrings().map { it.toDouble() }\n\nfun put(v: Any?) = writer.print(v)\nfun puts() = writer.println()\nfun puts(v: Any?) = writer.println(v)\n\nvar debug = false\nfun dp(v: Any?) {\n if (debug) println(v)\n}\nfun dp() {\n if (debug) println()\n}\n\nfun unique(list: List): MutableList {\n return TreeSet(list).toMutableList()\n}\n\nclass UFT(\n val N: Int\n) {\n val parent = Array(N) { it }\n val rank = Array(N) { 0 }\n\n fun root(x: Int): Int {\n if (parent[x] != x) {\n parent[x] = root(parent[x])\n }\n return parent[x]\n }\n fun same(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n fun unite(x: Int, y: Int) {\n val rootX = root(x)\n val rootY = root(y)\n if (rootX == rootY) {\n return\n }\n\n if (rank[rootX] < rank[rootY]) {\n parent[rootX] = rootY\n } else {\n parent[rootY] = rootX\n if (rank[rootX] == rank[rootY]) {\n ++rank[rootX]\n }\n }\n }\n}\n\nfun test(case: Int, input: String, expected: String) {\n reader = input.trimIndent().reader().buffered()\n\n val stringWriter = StringWriter()\n writer = PrintWriter(stringWriter)\n\n solve()\n writer.flush()\n\n val actual = stringWriter.toString()\n\n println(\"[test $case]\")\n if (\"${expected}\" == actual) {\n println(\"OK\")\n } else {\n println(\"NG\")\n println()\n println(\"expected: \\\"${expected}\\\"\")\n println(\"actual: \\\"${actual}\\\"\")\n }\n println()\n}\n\nfun main(args: Array) {\n if ((args.size == 1) && (args[0] == \"test\")) {\n testAll()\n } else {\n solve()\n writer.flush()\n }\n}\n\n///////////////////////////////////////////////////////////\n\nfun testAll() {\n debug = true\n\n test(1,\n \"\"\"\n 5 6\n 1 2 0\n 0 1 1\n 0 2 2\n -3 4 -1\n -2 6 3\n 1 0 1\n 0 1 2\n 2 0 2\n -1 -4 5\n 3 -2 4\n 1 2 4\n \"\"\",\n \"13\")\n test(2,\n \"\"\"\n 6 1\n -3 -1 -2\n -3 -1 1\n -2 -1 2\n 1 4 -2\n 1 4 -1\n 1 4 1\n 3 1 4\n \"\"\",\n \"INF\")\n}\n\nfun readToList(n: Int, transformer: (List) -> T): MutableList {\n return mutableListOf().also { list ->\n repeat(n) {\n val lines = nextLongs()\n list.add(transformer(lines))\n }\n }\n}\n\nclass Indexer(\n val X: Int,\n val Y: Int\n) {\n operator fun invoke(x: Int, y: Int): Int {\n return y * X + x\n }\n\n fun contentToString(arr: Array): String {\n val builder = StringBuilder()\n\n builder.appendln(\"----------\")\n for (y in 0 until Y) {\n for (x in 0 until X) {\n builder.append(arr[this(x, y)])\n builder.append(\", \")\n }\n builder.appendln()\n }\n builder.append(\"----------\")\n\n return builder.toString()\n }\n}\n\nval TOP = 1\nval BOTTOM = 2\nval LEFT = 4\nval RIGHT = 8\n\ntypealias Line = Pair\ntypealias Point = Pair\n\nfun doSolve(): Long {\n\n val (N, M) = nextInts()\n\n var Xseries = mutableListOf()\n Xseries.add(0L)\n\n var Yseries = mutableListOf()\n Yseries.add(0L)\n\n var HLines = mutableListOf>()\n var VLines = mutableListOf>()\n\n repeat(N) {\n val (a, b, c) = nextLongs()\n Xseries.add(a)\n Xseries.add(b)\n Yseries.add(c)\n\n HLines.add(Pair(c, Line(a, b)))\n }\n\n repeat(M) {\n val (d, e, f) = nextLongs()\n Xseries.add(d)\n Yseries.add(e)\n Yseries.add(f)\n\n VLines.add(Pair(d, Line(e, f)))\n }\n\n Xseries = unique(Xseries)\n Yseries = unique(Yseries)\n\n dp(Xseries)\n dp(Yseries)\n\n val X = Xseries.size + 2\n val Y = Yseries.size + 2\n val index = Indexer(X, Y)\n\n val uft = UFT(X*Y)\n\n val Hwalls = Array(X*Y) { 0 }\n val Vwalls = Array(X*Y) { 0 }\n HLines.forEach { (c, line) ->\n val (a, b) = line\n\n val xIdx1 = Xseries.binarySearch(a) + 1\n val xIdx2 = Xseries.binarySearch(b) + 1\n val yIdx = Yseries.binarySearch(c) + 1\n\n ++Hwalls[index(xIdx1, yIdx)]\n --Hwalls[index(xIdx2, yIdx)]\n }\n\n VLines.forEach { (d, line) ->\n val (e, f) = line\n\n val xIdx = Xseries.binarySearch(d) + 1\n val yIdx1 = Yseries.binarySearch(e) + 1\n val yIdx2 = Yseries.binarySearch(f) + 1\n\n ++Vwalls[index(xIdx, yIdx1)]\n --Vwalls[index(xIdx, yIdx2)]\n }\n\n for (y in 0 until Y) {\n for (x in 0 until X) {\n if (x > 0) Hwalls[index(x, y)] += Hwalls[index(x-1, y)]\n if (y > 0) Vwalls[index(x, y)] += Vwalls[index(x, y-1)]\n\n //dp(\"[$x, $y]: ${Hwalls[index(x, y)]}, ${Vwalls[index(x, y)]}\")\n if ((y > 0) && (Hwalls[index(x, y)] == 0)) {\n uft.unite(index(x, y), index(x, y-1))\n }\n if ((x > 0) && (Vwalls[index(x, y)] == 0)) {\n uft.unite(index(x, y), index(x-1, y))\n }\n }\n }\n\n dp(index.contentToString(uft.parent))\n\n var startX = Xseries.binarySearch(0L) + 1\n var startY = Yseries.binarySearch(0L) + 1\n\n val origin = uft.root(index(startX, startY))\n if (origin == uft.root(index(1, 0))) {\n return -1\n }\n dp(\"[$startX, $startY]: origin\")\n\n var area = 0L\n\n for (y in 1 until Y-2) {\n for (x in 1 until X-2) {\n if (uft.root(index(x, y)) == origin) {\n area += (Xseries[x]-Xseries[x-1]) * (Yseries[y]-Yseries[y-1])\n }\n }\n }\n\n return area\n}\n\nfun solve() {\n val ret = doSolve()\n if (ret >= 0) {\n put(ret)\n } else {\n put(\"INF\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1590802661, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02680.html", "problem_id": "p02680", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02680/input.txt", "sample_output_relpath": "derived/input_output/data/p02680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02680/Kotlin/s824126284.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s824126284", "user_id": "u116752827"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "//package abc168.F\n\nimport java.io.*\nimport java.math.*\nimport java.util.*\nimport kotlin.math.*\n\nvar reader: BufferedReader = System.`in`.bufferedReader()\nvar writer: PrintWriter = PrintWriter(System.`out`)\n\nfun next() = reader.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextStrings() = next().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\nfun nextDoubles() = nextStrings().map { it.toDouble() }\n\nfun put(v: Any?) = writer.print(v)\nfun puts() = writer.println()\nfun puts(v: Any?) = writer.println(v)\n\nvar debug = false\nfun dp(v: Any?) {\n if (debug) println(v)\n}\nfun dp() {\n if (debug) println()\n}\n\nfun unique(list: List): MutableList {\n return TreeSet(list).toMutableList()\n}\n\nclass UFT(\n val N: Int\n) {\n val parent = Array(N) { it }\n val rank = Array(N) { 0 }\n\n fun root(x: Int): Int {\n if (parent[x] != x) {\n parent[x] = root(parent[x])\n }\n return parent[x]\n }\n fun same(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n fun unite(x: Int, y: Int) {\n val rootX = root(x)\n val rootY = root(y)\n if (rootX == rootY) {\n return\n }\n\n if (rank[rootX] < rank[rootY]) {\n parent[rootX] = rootY\n } else {\n parent[rootY] = rootX\n if (rank[rootX] == rank[rootY]) {\n ++rank[rootX]\n }\n }\n }\n}\n\nfun test(case: Int, input: String, expected: String) {\n reader = input.trimIndent().reader().buffered()\n\n val stringWriter = StringWriter()\n writer = PrintWriter(stringWriter)\n\n solve()\n writer.flush()\n\n val actual = stringWriter.toString()\n\n println(\"[test $case]\")\n if (\"${expected}\" == actual) {\n println(\"OK\")\n } else {\n println(\"NG\")\n println()\n println(\"expected: \\\"${expected}\\\"\")\n println(\"actual: \\\"${actual}\\\"\")\n }\n println()\n}\n\nfun main(args: Array) {\n if ((args.size == 1) && (args[0] == \"test\")) {\n testAll()\n } else {\n solve()\n writer.flush()\n }\n}\n\n///////////////////////////////////////////////////////////\n\nfun testAll() {\n debug = true\n\n test(1,\n \"\"\"\n 5 6\n 1 2 0\n 0 1 1\n 0 2 2\n -3 4 -1\n -2 6 3\n 1 0 1\n 0 1 2\n 2 0 2\n -1 -4 5\n 3 -2 4\n 1 2 4\n \"\"\",\n \"13\")\n test(2,\n \"\"\"\n 6 1\n -3 -1 -2\n -3 -1 1\n -2 -1 2\n 1 4 -2\n 1 4 -1\n 1 4 1\n 3 1 4\n \"\"\",\n \"INF\")\n}\n\nfun readToList(n: Int, transformer: (List) -> T): MutableList {\n return mutableListOf().also { list ->\n repeat(n) {\n val lines = nextLongs()\n list.add(transformer(lines))\n }\n }\n}\n\nclass Indexer(\n val X: Int,\n val Y: Int\n) {\n operator fun invoke(x: Int, y: Int): Int {\n return y * X + x\n }\n\n fun contentToString(arr: Array): String {\n val builder = StringBuilder()\n\n builder.appendln(\"----------\")\n for (y in 0 until Y) {\n for (x in 0 until X) {\n builder.append(arr[this(x, y)])\n builder.append(\", \")\n }\n builder.appendln()\n }\n builder.append(\"----------\")\n\n return builder.toString()\n }\n}\n\nval TOP = 1\nval BOTTOM = 2\nval LEFT = 4\nval RIGHT = 8\n\ntypealias Line = Pair\ntypealias Point = Pair\n\nfun doSolve(): Long {\n\n val (N, M) = nextInts()\n\n var Xseries = mutableListOf()\n Xseries.add(0L)\n\n var Yseries = mutableListOf()\n Yseries.add(0L)\n\n var HLines = mutableListOf>()\n var VLines = mutableListOf>()\n\n repeat(N) {\n val (a, b, c) = nextLongs()\n Xseries.add(a)\n Xseries.add(b)\n Yseries.add(c)\n\n HLines.add(Pair(c, Line(a, b)))\n }\n\n repeat(M) {\n val (d, e, f) = nextLongs()\n Xseries.add(d)\n Yseries.add(e)\n Yseries.add(f)\n\n VLines.add(Pair(d, Line(e, f)))\n }\n\n Xseries = unique(Xseries)\n Yseries = unique(Yseries)\n\n dp(Xseries)\n dp(Yseries)\n\n val X = Xseries.size + 2\n val Y = Yseries.size + 2\n val index = Indexer(X, Y)\n\n val uft = UFT(X*Y)\n\n val Hwalls = Array(X*Y) { 0 }\n val Vwalls = Array(X*Y) { 0 }\n HLines.forEach { (c, line) ->\n val (a, b) = line\n\n val xIdx1 = Xseries.binarySearch(a) + 1\n val xIdx2 = Xseries.binarySearch(b) + 1\n val yIdx = Yseries.binarySearch(c) + 1\n\n ++Hwalls[index(xIdx1, yIdx)]\n --Hwalls[index(xIdx2, yIdx)]\n }\n\n VLines.forEach { (d, line) ->\n val (e, f) = line\n\n val xIdx = Xseries.binarySearch(d) + 1\n val yIdx1 = Yseries.binarySearch(e) + 1\n val yIdx2 = Yseries.binarySearch(f) + 1\n\n ++Vwalls[index(xIdx, yIdx1)]\n --Vwalls[index(xIdx, yIdx2)]\n }\n\n for (y in 0 until Y) {\n for (x in 0 until X) {\n if (x > 0) Hwalls[index(x, y)] += Hwalls[index(x-1, y)]\n if (y > 0) Vwalls[index(x, y)] += Vwalls[index(x, y-1)]\n\n //dp(\"[$x, $y]: ${Hwalls[index(x, y)]}, ${Vwalls[index(x, y)]}\")\n if ((y > 0) && (Hwalls[index(x, y)] == 0)) {\n uft.unite(index(x, y), index(x, y-1))\n }\n if ((x > 0) && (Vwalls[index(x, y)] == 0)) {\n uft.unite(index(x, y), index(x-1, y))\n }\n }\n }\n\n dp(index.contentToString(uft.parent))\n\n var startX = Xseries.binarySearch(0L) + 1\n var startY = Yseries.binarySearch(0L) + 1\n\n val origin = uft.root(index(startX, startY))\n if (origin == uft.root(index(1, 0))) {\n return -1\n }\n dp(\"[$startX, $startY]: origin\")\n\n var area = 0L\n\n for (y in 1 until Y-2) {\n for (x in 1 until X-2) {\n if (uft.root(index(x, y)) == origin) {\n area += (Xseries[x]-Xseries[x-1]) * (Yseries[y]-Yseries[y-1])\n }\n }\n }\n\n return area\n}\n\nfun solve() {\n val ret = doSolve()\n if (ret >= 0) {\n put(ret)\n } else {\n put(\"INF\")\n }\n}\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nThere is a grass field that stretches infinitely.\n\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\n\nThere are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).\n\nWhat is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF instead.\n\nConstraints\n\nAll values in input are integers between -10^9 and 10^9 (inclusive).\n\n1 \\leq N, M \\leq 1000\n\nA_i < B_i\\ (1 \\leq i \\leq N)\n\nE_j < F_j\\ (1 \\leq j \\leq M)\n\nThe point (0, 0) does not lie on any of the given segments.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1 C_1\n:\nA_N B_N C_N\nD_1 E_1 F_1\n:\nD_M E_M F_M\n\nOutput\n\nIf the area of the region the cow can reach is infinite, print INF; otherwise, print an integer representing the area in \\mathrm{cm^2}.\n\n(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)\n\nSample Input 1\n\n5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n\nSample Output 1\n\n13\n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\nSample Input 2\n\n6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n\nSample Output 2\n\nINF\n\nThe area of the region the cow can reach is infinite.", "sample_input": "5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02680", "source_text": "Score: 600 points\n\nProblem Statement\n\nThere is a grass field that stretches infinitely.\n\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\n\nThere are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).\n\nWhat is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF instead.\n\nConstraints\n\nAll values in input are integers between -10^9 and 10^9 (inclusive).\n\n1 \\leq N, M \\leq 1000\n\nA_i < B_i\\ (1 \\leq i \\leq N)\n\nE_j < F_j\\ (1 \\leq j \\leq M)\n\nThe point (0, 0) does not lie on any of the given segments.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1 C_1\n:\nA_N B_N C_N\nD_1 E_1 F_1\n:\nD_M E_M F_M\n\nOutput\n\nIf the area of the region the cow can reach is infinite, print INF; otherwise, print an integer representing the area in \\mathrm{cm^2}.\n\n(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)\n\nSample Input 1\n\n5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n\nSample Output 1\n\n13\n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\nSample Input 2\n\n6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n\nSample Output 2\n\nINF\n\nThe area of the region the cow can reach is infinite.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6190, "cpu_time_ms": 3329, "memory_kb": 846540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s777683435", "group_id": "codeNet:p02680", "input_text": "//package abc168.F\n\nimport java.io.*\nimport java.math.*\nimport java.util.*\nimport kotlin.math.*\n\nvar reader: BufferedReader = System.`in`.bufferedReader()\nvar writer: PrintWriter = PrintWriter(System.`out`)\n\nfun next() = reader.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextStrings() = next().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\nfun nextDoubles() = nextStrings().map { it.toDouble() }\n\nfun put(v: Any?) = writer.print(v)\nfun puts() = writer.println()\nfun puts(v: Any?) = writer.println(v)\n\nvar debug = false\nfun dp(v: Any?) {\n if (debug) println(v)\n}\nfun dp() {\n if (debug) println()\n}\n\nfun unique(list: List): MutableList {\n return TreeSet(list).toMutableList()\n}\n\nclass UFT(\n val N: Int\n) {\n private val parent = Array(N) { it }\n private val rank = Array(N) { 0 }\n\n fun root(x: Int): Int {\n if (parent[x] != x) {\n parent[x] = root(parent[x])\n }\n return parent[x]\n }\n fun same(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n fun unite(x: Int, y: Int) {\n val rootX = root(x)\n val rootY = root(y)\n if (rootX == rootY) {\n return\n }\n\n if (rank[rootX] < rank[rootY]) {\n parent[rootX] = rootY\n } else {\n parent[rootY] = rootX\n if (rank[rootX] == rank[rootY]) {\n ++rank[rootX]\n }\n }\n }\n}\n\nfun test(case: Int, input: String, expected: String) {\n reader = input.trimIndent().reader().buffered()\n\n val stringWriter = StringWriter()\n writer = PrintWriter(stringWriter)\n\n solve()\n writer.flush()\n\n val actual = stringWriter.toString()\n\n println(\"[test $case]\")\n if (\"${expected}\" == actual) {\n println(\"OK\")\n } else {\n println(\"NG\")\n println()\n println(\"expected: \\\"${expected}\\\"\")\n println(\"actual: \\\"${actual}\\\"\")\n }\n println()\n}\n\nfun main(args: Array) {\n if ((args.size == 1) && (args[0] == \"test\")) {\n testAll()\n } else {\n solve()\n writer.flush()\n }\n}\n\n///////////////////////////////////////////////////////////\n\nfun testAll() {\n debug = true\n\n test(1,\n \"\"\"\n 5 6\n 1 2 0\n 0 1 1\n 0 2 2\n -3 4 -1\n -2 6 3\n 1 0 1\n 0 1 2\n 2 0 2\n -1 -4 5\n 3 -2 4\n 1 2 4\n \"\"\",\n \"13\")\n test(2,\n \"\"\"\n 6 1\n -3 -1 -2\n -3 -1 1\n -2 -1 2\n 1 4 -2\n 1 4 -1\n 1 4 1\n 3 1 4\n \"\"\",\n \"INF\")\n}\n\nfun readToList(n: Int, transformer: (List) -> T): MutableList {\n return mutableListOf().also { list ->\n repeat(n) {\n val lines = nextLongs()\n list.add(transformer(lines))\n }\n }\n}\n\nclass Indexer(\n val X: Int,\n val Y: Int\n) {\n operator fun invoke(x: Int, y: Int): Int {\n return y * X + x\n }\n\n fun contentToString(arr: Array): String {\n val builder = StringBuilder()\n\n builder.appendln(\"----------\")\n for (y in 0 until Y) {\n for (x in 0 until X) {\n builder.append(arr[this(x, y)])\n builder.append(\", \")\n }\n builder.appendln()\n }\n builder.append(\"----------\")\n\n return builder.toString()\n }\n}\n\nval TOP = 1\nval BOTTOM = 2\nval LEFT = 4\nval RIGHT = 8\n\ntypealias Line = Pair\ntypealias Point = Pair\n\nfun doSolve(): Long {\n\n val (N, M) = nextInts()\n\n var Xseries = mutableListOf()\n var Yseries = mutableListOf()\n\n var HLines = mutableListOf>()\n var VLines = mutableListOf>()\n\n repeat(N) {\n val (a, b, c) = nextLongs()\n Xseries.add(a)\n Xseries.add(b)\n Yseries.add(c)\n\n HLines.add(Pair(c, Line(a, b)))\n }\n\n repeat(M) {\n val (d, e, f) = nextLongs()\n Xseries.add(d)\n Yseries.add(e)\n Yseries.add(f)\n\n VLines.add(Pair(d, Line(e, f)))\n }\n\n Xseries = unique(Xseries)\n Yseries = unique(Yseries)\n\n dp(Xseries)\n dp(Yseries)\n\n val X = Xseries.size + 2\n val Y = Yseries.size + 2\n val index = Indexer(X, Y)\n\n val areas = Array(X*Y) { -1 }\n\n var startX = 0\n var startY = 0\n\n for (y in 1 until Yseries.size) {\n val c1 = Yseries[y-1]\n val c2 = Yseries[y]\n\n for (x in 1 until Xseries.size) {\n val d1 = Xseries[x-1]\n val d2 = Xseries[x]\n\n val area = (c2 - c1) * (d2 - d1)\n areas[index(x, y)] = area\n\n if ((c1 <= 0) && (0 < c2) && (d1 <= 0) && (0 < d2)) {\n startX = x\n startY = y\n }\n }\n }\n dp(\"[$startX, $startY]\")\n\n val Hwalls = Array(X*Y) { 0 }\n HLines.forEach { (c, line) ->\n val (a, b) = line\n\n val xIdx1 = Xseries.binarySearch(a) + 1\n val xIdx2 = Xseries.binarySearch(b) + 1\n val yIdx = Yseries.binarySearch(c) + 1\n\n ++Hwalls[index(xIdx1, yIdx)]\n --Hwalls[index(xIdx2, yIdx)]\n }\n //dp(\"Hwall: ${index.contentToString(Hwalls)}\")\n\n val Vwalls = Array(X*Y) { 0 }\n VLines.forEach { (d, line) ->\n val (e, f) = line\n\n val xIdx = Xseries.binarySearch(d) + 1\n val yIdy1 = Yseries.binarySearch(e) + 1\n val yIdy2 = Yseries.binarySearch(f) + 1\n\n ++Vwalls[index(xIdx, yIdy1)]\n --Vwalls[index(xIdx, yIdy2)]\n }\n //dp(\"Vwall: ${index.contentToString(Vwalls)}\")\n\n val uft = UFT(X*Y)\n var Vwall = Array(X) { 0 }\n var Hwall = Array(Y) { 0 }\n for (y in 1 until Y-1) {\n for (x in 1 until X-1) {\n Vwall[x] += Vwalls[index(x, y)]\n Hwall[y] += Hwalls[index(x, y)]\n\n dp(\"($x, $y) -> ${Hwall[x]}, ${Vwall[y]}\")\n\n if (Vwall[x] <= 0) {\n uft.unite(index(x, y), index(x-1, y))\n }\n if (Hwall[y] <= 0) {\n uft.unite(index(x, y), index(x, y-1))\n }\n }\n }\n dp()\n\n var area = 0L\n val visited = mutableSetOf()\n\n val queue = ArrayDeque>()\n queue.add(Pair(startX, startY))\n\n val accessible = uft.root(index(startX, startY))\n\n while (!queue.isEmpty()) {\n val p= queue.remove()\n dp(\"pop: $p\")\n if (!visited.add(p)) {\n continue;\n }\n\n val (x, y) = p\n val a = areas[index(x, y)]\n dp(\"area: $a\")\n if (a < 0) {\n return -1\n }\n\n area += a\n dp(\"-> $area\")\n\n if (uft.root(index(x, y+1)) == accessible) {\n dp(\"queue: ($x, ${y+1})\")\n queue.add(Point(x, y+1))\n }\n if (uft.root(index(x, y-1)) == accessible) {\n dp(\"queue: ($x, ${y-1})\")\n queue.add(Point(x, y-1))\n }\n if (uft.root(index(x-1, y)) == accessible) {\n dp(\"queue: (${x-1}, $y)\")\n queue.add(Point(x-1, y))\n }\n if (uft.root(index(x+1, y)) == accessible) {\n dp(\"queue: (${x+1}, $y)\")\n queue.add(Point(x+1, y))\n }\n\n dp()\n }\n\n return area\n}\n\nfun solve() {\n val ret = doSolve()\n if (ret >= 0) {\n put(ret)\n } else {\n put(\"INF\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1590785657, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02680.html", "problem_id": "p02680", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02680/input.txt", "sample_output_relpath": "derived/input_output/data/p02680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02680/Kotlin/s777683435.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s777683435", "user_id": "u116752827"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "//package abc168.F\n\nimport java.io.*\nimport java.math.*\nimport java.util.*\nimport kotlin.math.*\n\nvar reader: BufferedReader = System.`in`.bufferedReader()\nvar writer: PrintWriter = PrintWriter(System.`out`)\n\nfun next() = reader.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextStrings() = next().split(\" \")\nfun nextInts() = nextStrings().map { it.toInt() }\nfun nextLongs() = nextStrings().map { it.toLong() }\nfun nextDoubles() = nextStrings().map { it.toDouble() }\n\nfun put(v: Any?) = writer.print(v)\nfun puts() = writer.println()\nfun puts(v: Any?) = writer.println(v)\n\nvar debug = false\nfun dp(v: Any?) {\n if (debug) println(v)\n}\nfun dp() {\n if (debug) println()\n}\n\nfun unique(list: List): MutableList {\n return TreeSet(list).toMutableList()\n}\n\nclass UFT(\n val N: Int\n) {\n private val parent = Array(N) { it }\n private val rank = Array(N) { 0 }\n\n fun root(x: Int): Int {\n if (parent[x] != x) {\n parent[x] = root(parent[x])\n }\n return parent[x]\n }\n fun same(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n fun unite(x: Int, y: Int) {\n val rootX = root(x)\n val rootY = root(y)\n if (rootX == rootY) {\n return\n }\n\n if (rank[rootX] < rank[rootY]) {\n parent[rootX] = rootY\n } else {\n parent[rootY] = rootX\n if (rank[rootX] == rank[rootY]) {\n ++rank[rootX]\n }\n }\n }\n}\n\nfun test(case: Int, input: String, expected: String) {\n reader = input.trimIndent().reader().buffered()\n\n val stringWriter = StringWriter()\n writer = PrintWriter(stringWriter)\n\n solve()\n writer.flush()\n\n val actual = stringWriter.toString()\n\n println(\"[test $case]\")\n if (\"${expected}\" == actual) {\n println(\"OK\")\n } else {\n println(\"NG\")\n println()\n println(\"expected: \\\"${expected}\\\"\")\n println(\"actual: \\\"${actual}\\\"\")\n }\n println()\n}\n\nfun main(args: Array) {\n if ((args.size == 1) && (args[0] == \"test\")) {\n testAll()\n } else {\n solve()\n writer.flush()\n }\n}\n\n///////////////////////////////////////////////////////////\n\nfun testAll() {\n debug = true\n\n test(1,\n \"\"\"\n 5 6\n 1 2 0\n 0 1 1\n 0 2 2\n -3 4 -1\n -2 6 3\n 1 0 1\n 0 1 2\n 2 0 2\n -1 -4 5\n 3 -2 4\n 1 2 4\n \"\"\",\n \"13\")\n test(2,\n \"\"\"\n 6 1\n -3 -1 -2\n -3 -1 1\n -2 -1 2\n 1 4 -2\n 1 4 -1\n 1 4 1\n 3 1 4\n \"\"\",\n \"INF\")\n}\n\nfun readToList(n: Int, transformer: (List) -> T): MutableList {\n return mutableListOf().also { list ->\n repeat(n) {\n val lines = nextLongs()\n list.add(transformer(lines))\n }\n }\n}\n\nclass Indexer(\n val X: Int,\n val Y: Int\n) {\n operator fun invoke(x: Int, y: Int): Int {\n return y * X + x\n }\n\n fun contentToString(arr: Array): String {\n val builder = StringBuilder()\n\n builder.appendln(\"----------\")\n for (y in 0 until Y) {\n for (x in 0 until X) {\n builder.append(arr[this(x, y)])\n builder.append(\", \")\n }\n builder.appendln()\n }\n builder.append(\"----------\")\n\n return builder.toString()\n }\n}\n\nval TOP = 1\nval BOTTOM = 2\nval LEFT = 4\nval RIGHT = 8\n\ntypealias Line = Pair\ntypealias Point = Pair\n\nfun doSolve(): Long {\n\n val (N, M) = nextInts()\n\n var Xseries = mutableListOf()\n var Yseries = mutableListOf()\n\n var HLines = mutableListOf>()\n var VLines = mutableListOf>()\n\n repeat(N) {\n val (a, b, c) = nextLongs()\n Xseries.add(a)\n Xseries.add(b)\n Yseries.add(c)\n\n HLines.add(Pair(c, Line(a, b)))\n }\n\n repeat(M) {\n val (d, e, f) = nextLongs()\n Xseries.add(d)\n Yseries.add(e)\n Yseries.add(f)\n\n VLines.add(Pair(d, Line(e, f)))\n }\n\n Xseries = unique(Xseries)\n Yseries = unique(Yseries)\n\n dp(Xseries)\n dp(Yseries)\n\n val X = Xseries.size + 2\n val Y = Yseries.size + 2\n val index = Indexer(X, Y)\n\n val areas = Array(X*Y) { -1 }\n\n var startX = 0\n var startY = 0\n\n for (y in 1 until Yseries.size) {\n val c1 = Yseries[y-1]\n val c2 = Yseries[y]\n\n for (x in 1 until Xseries.size) {\n val d1 = Xseries[x-1]\n val d2 = Xseries[x]\n\n val area = (c2 - c1) * (d2 - d1)\n areas[index(x, y)] = area\n\n if ((c1 <= 0) && (0 < c2) && (d1 <= 0) && (0 < d2)) {\n startX = x\n startY = y\n }\n }\n }\n dp(\"[$startX, $startY]\")\n\n val Hwalls = Array(X*Y) { 0 }\n HLines.forEach { (c, line) ->\n val (a, b) = line\n\n val xIdx1 = Xseries.binarySearch(a) + 1\n val xIdx2 = Xseries.binarySearch(b) + 1\n val yIdx = Yseries.binarySearch(c) + 1\n\n ++Hwalls[index(xIdx1, yIdx)]\n --Hwalls[index(xIdx2, yIdx)]\n }\n //dp(\"Hwall: ${index.contentToString(Hwalls)}\")\n\n val Vwalls = Array(X*Y) { 0 }\n VLines.forEach { (d, line) ->\n val (e, f) = line\n\n val xIdx = Xseries.binarySearch(d) + 1\n val yIdy1 = Yseries.binarySearch(e) + 1\n val yIdy2 = Yseries.binarySearch(f) + 1\n\n ++Vwalls[index(xIdx, yIdy1)]\n --Vwalls[index(xIdx, yIdy2)]\n }\n //dp(\"Vwall: ${index.contentToString(Vwalls)}\")\n\n val uft = UFT(X*Y)\n var Vwall = Array(X) { 0 }\n var Hwall = Array(Y) { 0 }\n for (y in 1 until Y-1) {\n for (x in 1 until X-1) {\n Vwall[x] += Vwalls[index(x, y)]\n Hwall[y] += Hwalls[index(x, y)]\n\n dp(\"($x, $y) -> ${Hwall[x]}, ${Vwall[y]}\")\n\n if (Vwall[x] <= 0) {\n uft.unite(index(x, y), index(x-1, y))\n }\n if (Hwall[y] <= 0) {\n uft.unite(index(x, y), index(x, y-1))\n }\n }\n }\n dp()\n\n var area = 0L\n val visited = mutableSetOf()\n\n val queue = ArrayDeque>()\n queue.add(Pair(startX, startY))\n\n val accessible = uft.root(index(startX, startY))\n\n while (!queue.isEmpty()) {\n val p= queue.remove()\n dp(\"pop: $p\")\n if (!visited.add(p)) {\n continue;\n }\n\n val (x, y) = p\n val a = areas[index(x, y)]\n dp(\"area: $a\")\n if (a < 0) {\n return -1\n }\n\n area += a\n dp(\"-> $area\")\n\n if (uft.root(index(x, y+1)) == accessible) {\n dp(\"queue: ($x, ${y+1})\")\n queue.add(Point(x, y+1))\n }\n if (uft.root(index(x, y-1)) == accessible) {\n dp(\"queue: ($x, ${y-1})\")\n queue.add(Point(x, y-1))\n }\n if (uft.root(index(x-1, y)) == accessible) {\n dp(\"queue: (${x-1}, $y)\")\n queue.add(Point(x-1, y))\n }\n if (uft.root(index(x+1, y)) == accessible) {\n dp(\"queue: (${x+1}, $y)\")\n queue.add(Point(x+1, y))\n }\n\n dp()\n }\n\n return area\n}\n\nfun solve() {\n val ret = doSolve()\n if (ret >= 0) {\n put(ret)\n } else {\n put(\"INF\")\n }\n}\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nThere is a grass field that stretches infinitely.\n\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\n\nThere are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).\n\nWhat is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF instead.\n\nConstraints\n\nAll values in input are integers between -10^9 and 10^9 (inclusive).\n\n1 \\leq N, M \\leq 1000\n\nA_i < B_i\\ (1 \\leq i \\leq N)\n\nE_j < F_j\\ (1 \\leq j \\leq M)\n\nThe point (0, 0) does not lie on any of the given segments.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1 C_1\n:\nA_N B_N C_N\nD_1 E_1 F_1\n:\nD_M E_M F_M\n\nOutput\n\nIf the area of the region the cow can reach is infinite, print INF; otherwise, print an integer representing the area in \\mathrm{cm^2}.\n\n(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)\n\nSample Input 1\n\n5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n\nSample Output 1\n\n13\n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\nSample Input 2\n\n6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n\nSample Output 2\n\nINF\n\nThe area of the region the cow can reach is infinite.", "sample_input": "5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02680", "source_text": "Score: 600 points\n\nProblem Statement\n\nThere is a grass field that stretches infinitely.\n\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\n\nThere are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).\n\nWhat is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF instead.\n\nConstraints\n\nAll values in input are integers between -10^9 and 10^9 (inclusive).\n\n1 \\leq N, M \\leq 1000\n\nA_i < B_i\\ (1 \\leq i \\leq N)\n\nE_j < F_j\\ (1 \\leq j \\leq M)\n\nThe point (0, 0) does not lie on any of the given segments.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1 C_1\n:\nA_N B_N C_N\nD_1 E_1 F_1\n:\nD_M E_M F_M\n\nOutput\n\nIf the area of the region the cow can reach is infinite, print INF; otherwise, print an integer representing the area in \\mathrm{cm^2}.\n\n(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)\n\nSample Input 1\n\n5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n\nSample Output 1\n\n13\n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\nSample Input 2\n\n6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n\nSample Output 2\n\nINF\n\nThe area of the region the cow can reach is infinite.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7348, "cpu_time_ms": 3328, "memory_kb": 813788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s749830219", "group_id": "codeNet:p02681", "input_text": "fun main (args:Array){\n val badid = readLine()!!\n val newid = readLine()!!\n if(badid == newid.dropLast(1)){\n print(\"Yes\")\n }\n else{\n print(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1593012397, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Kotlin/s749830219.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749830219", "user_id": "u838133978"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main (args:Array){\n val badid = readLine()!!\n val newid = readLine()!!\n if(badid == newid.dropLast(1)){\n print(\"Yes\")\n }\n else{\n print(\"No\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 190, "cpu_time_ms": 108, "memory_kb": 35992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s985588141", "group_id": "codeNet:p02681", "input_text": "fun main(args: Array) {\n println(args)\n val input = args[0].split(\"\\n\")\n val s = input[0]\n val t = input[1]\n \n if (s.length !in 1..10 || s.length != t.length - 1) {\n println(\"No\")\n return\n }\n if (t.startsWith(s)) {\n println(\"Yes\") \n } else {\n println(\"No\") \n }\n}", "language": "Kotlin", "metadata": {"date": 1589312018, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Kotlin/s985588141.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s985588141", "user_id": "u613883692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n println(args)\n val input = args[0].split(\"\\n\")\n val s = input[0]\n val t = input[1]\n \n if (s.length !in 1..10 || s.length != t.length - 1) {\n println(\"No\")\n return\n }\n if (t.startsWith(s)) {\n println(\"Yes\") \n } else {\n println(\"No\") \n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 100, "memory_kb": 36180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s801174444", "group_id": "codeNet:p02681", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n\n if (t.substring(0, t.length-1) == s) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1589163361, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Kotlin/s801174444.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s801174444", "user_id": "u099066216"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val t = readLine()!!\n\n if (t.substring(0, t.length-1) == s) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 191, "cpu_time_ms": 94, "memory_kb": 34316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s549678967", "group_id": "codeNet:p02681", "input_text": "fun main(args: Array) {\n val (s, t) = readLine()!!.split(\" \").map{it}\n val sub = t.substring(0, t.length -1)\n \n if (sub.equals(s)) println(\"Yes\") else println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1589162126, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Kotlin/s549678967.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s549678967", "user_id": "u952914882"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (s, t) = readLine()!!.split(\" \").map{it}\n val sub = t.substring(0, t.length -1)\n \n if (sub.equals(s)) println(\"Yes\") else println(\"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 117, "memory_kb": 37484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s325564535", "group_id": "codeNet:p02681", "input_text": "fun main(){\n val s = readLine()!!\n val t = readLine()!!\n if(s == t.substring(0, s.length)){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1589158925, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Kotlin/s325564535.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s325564535", "user_id": "u531770859"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(){\n val s = readLine()!!\n val t = readLine()!!\n if(s == t.substring(0, s.length)){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 164, "cpu_time_ms": 85, "memory_kb": 34556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s104589887", "group_id": "codeNet:p02681", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val s = next()\n val t = next()\n for (i in s.indices) {\n if(s[i] != t[i]) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n\n\n}\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1589158869, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Kotlin/s104589887.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104589887", "user_id": "u581625805"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val s = next()\n val t = next()\n for (i in s.indices) {\n if(s[i] != t[i]) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n\n\n}\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14320, "cpu_time_ms": 93, "memory_kb": 34696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s770378397", "group_id": "codeNet:p02682", "input_text": "fun main(args: Array) {\n val (A, B, C, K) = readLine()!!.split(\" \").map { it.toLong() }\n\n// var amount = K\n \n// val a = if (amount > A) {\n// amount -= A\n// A\n// } else {\n// val tmp = amount\n// amount = 0\n// tmp\n// }\n//\n// val b = if (amount > B) {\n// amount -= B\n// B\n// } else {\n// val tmp = amount\n// amount = 0\n// tmp\n// }\n//\n// val c = if (amount > C) {\n// amount -= C\n// C\n// } else {\n// amount\n// }\n fun calc(numElemnts: List, amount: Long, calcResult: List = listOf(), index: Int = 1): List {\n val targetNum = numElemnts[index - 1]\n val (newAmount, addElement) = if (amount > targetNum) Pair(amount - targetNum, targetNum) else Pair(0L, amount)\n val newCalcResult = calcResult.plusElement(addElement)\n \n return if (index == numElemnts.size) {\n newCalcResult\n } else calc(numElemnts, newAmount, newCalcResult, index + 1)\n }\n \n val (a, _, c) = calc(listOf(A,B,C), K)\n\n println(a - c)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1600119060, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Kotlin/s770378397.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770378397", "user_id": "u496449946"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B, C, K) = readLine()!!.split(\" \").map { it.toLong() }\n\n// var amount = K\n \n// val a = if (amount > A) {\n// amount -= A\n// A\n// } else {\n// val tmp = amount\n// amount = 0\n// tmp\n// }\n//\n// val b = if (amount > B) {\n// amount -= B\n// B\n// } else {\n// val tmp = amount\n// amount = 0\n// tmp\n// }\n//\n// val c = if (amount > C) {\n// amount -= C\n// C\n// } else {\n// amount\n// }\n fun calc(numElemnts: List, amount: Long, calcResult: List = listOf(), index: Int = 1): List {\n val targetNum = numElemnts[index - 1]\n val (newAmount, addElement) = if (amount > targetNum) Pair(amount - targetNum, targetNum) else Pair(0L, amount)\n val newCalcResult = calcResult.plusElement(addElement)\n \n return if (index == numElemnts.size) {\n newCalcResult\n } else calc(numElemnts, newAmount, newCalcResult, index + 1)\n }\n \n val (a, _, c) = calc(listOf(A,B,C), K)\n\n println(a - c)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1109, "cpu_time_ms": 125, "memory_kb": 38956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s688541879", "group_id": "codeNet:p02682", "input_text": "fun main(){\n val (a,b, c, k) = readLine()!!.split(\" \").map(String::toInt)\n\n if(a >= k){\n print(\"$k\")\n }\n else if(a < k && a+b >= k){\n print(\"$a\")\n }\n else{\n val max = a+(k-a-b)*(-1)\n print(max.toString())\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1589162137, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Kotlin/s688541879.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s688541879", "user_id": "u059982665"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(){\n val (a,b, c, k) = readLine()!!.split(\" \").map(String::toInt)\n\n if(a >= k){\n print(\"$k\")\n }\n else if(a < k && a+b >= k){\n print(\"$a\")\n }\n else{\n val max = a+(k-a-b)*(-1)\n print(max.toString())\n }\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 94, "memory_kb": 36296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s071083392", "group_id": "codeNet:p02682", "input_text": "fun main(args: Array) {\n val i = readLine()!!.split(\" \").map { it.toInt() }\n print(\n when {\n i[3] - i[0] - i[1] > 0 -> i[0] - (i[3] - i[0] - i[1])\n else -> i[0]\n }\n )\n}", "language": "Kotlin", "metadata": {"date": 1589161860, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Kotlin/s071083392.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s071083392", "user_id": "u784615990"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val i = readLine()!!.split(\" \").map { it.toInt() }\n print(\n when {\n i[3] - i[0] - i[1] > 0 -> i[0] - (i[3] - i[0] - i[1])\n else -> i[0]\n }\n )\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 107, "memory_kb": 36404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s674762231", "group_id": "codeNet:p02682", "input_text": "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 val k = sc.nextInt()\n\n println(abc167b(a, b, c, k))\n}\n\nprivate fun abc167b(a: Int, b: Int, c: Int, k: Int): Int {\n val ka = k - a\n if (ka <= 0) return a\n val kab = ka - b\n if (kab <= 0) return a\n\n return a - kab\n}\n", "language": "Kotlin", "metadata": {"date": 1589161808, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Kotlin/s674762231.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s674762231", "user_id": "u323522006"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "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 val k = sc.nextInt()\n\n println(abc167b(a, b, c, k))\n}\n\nprivate fun abc167b(a: Int, b: Int, c: Int, k: Int): Int {\n val ka = k - a\n if (ka <= 0) return a\n val kab = ka - b\n if (kab <= 0) return a\n\n return a - kab\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 119, "memory_kb": 36408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s955214707", "group_id": "codeNet:p02685", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\n// region\nclass ModInt(x: Long) {\n\n companion object {\n const val MOD = 998244353L\n }\n\n val x = (x % MOD + MOD) % MOD\n\n operator fun plus(other: ModInt): ModInt {\n return ModInt(x + other.x)\n }\n\n operator fun minus(other: ModInt): ModInt {\n return ModInt(x - other.x)\n }\n\n operator fun times(other: ModInt): ModInt {\n return ModInt(x * other.x)\n }\n\n operator fun div(other: ModInt): ModInt {\n return this * other.inv()\n }\n\n fun pow(exp: Long): ModInt {\n if (exp == 0L) return ModInt(1L)\n var a = pow(exp shr 1)\n a *= a\n if (exp and 1L == 0L) return a\n return this * a\n }\n\n fun inv(): ModInt {\n return this.pow(MOD - 2)\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n\n other as ModInt\n\n if (x != other.x) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n return x.hashCode()\n }\n\n override fun toString(): String {\n return \"$x\"\n }\n\n}\n\nval fac = mutableListOf()\n\nfun fact(n: Long): ModInt {\n if (fac.count() == 0) fac.add(ModInt(1))\n while (fac.count() <= n) {\n fac.add(fac.last() * ModInt(fac.count().toLong()))\n }\n return fac[n.toInt()]\n}\n\nfun comb(n: Long, k: Long): ModInt {\n return fact(n) / fact(k) / fact(n - k)\n}\n\nfun comb2(n: Long, k: Long): ModInt {\n var ans = ModInt(1)\n for (i in 0 until k) {\n ans = ans * ModInt(n - i) / ModInt(k - i)\n }\n return ans\n}\n// endregion\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextLong()\n val m = sc.nextLong()\n val k = sc.nextLong()\n var ans = ModInt(0)\n for (i in 0..k) {\n val v = ModInt(m) * ModInt(m - 1).pow(n - i - 1) * comb(n - 1, i)\n ans += v\n }\n println(ans)\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}", "language": "Kotlin", "metadata": {"date": 1589161103, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02685.html", "problem_id": "p02685", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02685/input.txt", "sample_output_relpath": "derived/input_output/data/p02685/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02685/Kotlin/s955214707.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s955214707", "user_id": "u190507186"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\n// region\nclass ModInt(x: Long) {\n\n companion object {\n const val MOD = 998244353L\n }\n\n val x = (x % MOD + MOD) % MOD\n\n operator fun plus(other: ModInt): ModInt {\n return ModInt(x + other.x)\n }\n\n operator fun minus(other: ModInt): ModInt {\n return ModInt(x - other.x)\n }\n\n operator fun times(other: ModInt): ModInt {\n return ModInt(x * other.x)\n }\n\n operator fun div(other: ModInt): ModInt {\n return this * other.inv()\n }\n\n fun pow(exp: Long): ModInt {\n if (exp == 0L) return ModInt(1L)\n var a = pow(exp shr 1)\n a *= a\n if (exp and 1L == 0L) return a\n return this * a\n }\n\n fun inv(): ModInt {\n return this.pow(MOD - 2)\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n\n other as ModInt\n\n if (x != other.x) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n return x.hashCode()\n }\n\n override fun toString(): String {\n return \"$x\"\n }\n\n}\n\nval fac = mutableListOf()\n\nfun fact(n: Long): ModInt {\n if (fac.count() == 0) fac.add(ModInt(1))\n while (fac.count() <= n) {\n fac.add(fac.last() * ModInt(fac.count().toLong()))\n }\n return fac[n.toInt()]\n}\n\nfun comb(n: Long, k: Long): ModInt {\n return fact(n) / fact(k) / fact(n - k)\n}\n\nfun comb2(n: Long, k: Long): ModInt {\n var ans = ModInt(1)\n for (i in 0 until k) {\n ans = ans * ModInt(n - i) / ModInt(k - i)\n }\n return ans\n}\n// endregion\n\nfun PrintWriter.solve(sc: FastScanner) {\n val n = sc.nextLong()\n val m = sc.nextLong()\n val k = sc.nextLong()\n var ans = ModInt(0)\n for (i in 0..k) {\n val v = ModInt(m) * ModInt(m - 1).pow(n - i - 1) * comb(n - 1, i)\n ans += v\n }\n println(ans)\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}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N blocks arranged in a row. Let us paint these blocks.\n\nWe will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.\n\nFind the number of ways to paint the blocks under the following conditions:\n\nFor each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors.\n\nThere may be at most K pairs of adjacent blocks that are painted in the same color.\n\nSince the count may be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 2 \\times 10^5\n\n0 \\leq K \\leq N - 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2 1\n\nSample Output 1\n\n6\n\nThe following ways to paint the blocks satisfy the conditions: 112, 121, 122, 211, 212, and 221. Here, digits represent the colors of the blocks.\n\nSample Input 2\n\n100 100 0\n\nSample Output 2\n\n73074801\n\nSample Input 3\n\n60522 114575 7559\n\nSample Output 3\n\n479519525", "sample_input": "3 2 1\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02685", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N blocks arranged in a row. Let us paint these blocks.\n\nWe will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.\n\nFind the number of ways to paint the blocks under the following conditions:\n\nFor each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors.\n\nThere may be at most K pairs of adjacent blocks that are painted in the same color.\n\nSince the count may be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 2 \\times 10^5\n\n0 \\leq K \\leq N - 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2 1\n\nSample Output 1\n\n6\n\nThe following ways to paint the blocks satisfy the conditions: 112, 121, 122, 211, 212, and 221. Here, digits represent the colors of the blocks.\n\nSample Input 2\n\n100 100 0\n\nSample Output 2\n\n73074801\n\nSample Input 3\n\n60522 114575 7559\n\nSample Output 3\n\n479519525", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2657, "cpu_time_ms": 458, "memory_kb": 61888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s074361359", "group_id": "codeNet:p02688", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.floor\n\nval pw = PrintWriter(System.out)\nval sc = Scanner(System.`in`)\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val (n, k) = nextListOfInt()\n val arr: MutableList = mutableListOf()\n for(i in 0 until k){\n val d = sc.nextInt()\n for(j in 0 until d){\n arr.add(sc.nextInt())\n }\n }\n val arrr = arr.toIntArray().distinct()\n var count = 0;\n for(i in 1..n){\n if(!arrr.contains(i)) count++\n }\n println(count)\n}\n\nfun abc000a(n:String) {\n}\n\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextListOfString() = next().split(\" \")\nfun nextListOfInt() = nextListOfString().map { it.toInt() }\nfun nextListOfLong() = nextListOfString().map { it.toLong() }\nfun nextListOfDouble() = nextListOfString().map { it.toDouble() }\n\n", "language": "Kotlin", "metadata": {"date": 1588555222, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/Kotlin/s074361359.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074361359", "user_id": "u240901574"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.math.floor\n\nval pw = PrintWriter(System.out)\nval sc = Scanner(System.`in`)\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val (n, k) = nextListOfInt()\n val arr: MutableList = mutableListOf()\n for(i in 0 until k){\n val d = sc.nextInt()\n for(j in 0 until d){\n arr.add(sc.nextInt())\n }\n }\n val arrr = arr.toIntArray().distinct()\n var count = 0;\n for(i in 1..n){\n if(!arrr.contains(i)) count++\n }\n println(count)\n}\n\nfun abc000a(n:String) {\n}\n\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextListOfString() = next().split(\" \")\nfun nextListOfInt() = nextListOfString().map { it.toInt() }\nfun nextListOfLong() = nextListOfString().map { it.toLong() }\nfun nextListOfDouble() = nextListOfString().map { it.toDouble() }\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 987, "cpu_time_ms": 245, "memory_kb": 52480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s463380736", "group_id": "codeNet:p02688", "input_text": "import java.util.Scanner\n\nfun main() {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval k = scn.nextInt()\n\tval arr = BooleanArray(n){false}\n\trepeat(k) {\n\t\tval d = scn.nextInt()\n\t\trepeat(d){\n\t\t\tarr[scn.nextInt()-1] = true\n\t\t}\n\t}\n\tprintln(arr.count{!it})\n}", "language": "Kotlin", "metadata": {"date": 1588554372, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/Kotlin/s463380736.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s463380736", "user_id": "u914590612"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main() {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval k = scn.nextInt()\n\tval arr = BooleanArray(n){false}\n\trepeat(k) {\n\t\tval d = scn.nextInt()\n\t\trepeat(d){\n\t\t\tarr[scn.nextInt()-1] = true\n\t\t}\n\t}\n\tprintln(arr.count{!it})\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 198, "memory_kb": 46716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s077830080", "group_id": "codeNet:p02689", "input_text": "import java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var (n,m) = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var arr = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n\n var map = HashMap()\n for(i in 1..m)\n {\n var (a,b) = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n\n if(map.contains(a))\n {\n map.put(a, Math.max(map.get(a)!!,b))\n }\n else\n {\n map.put(a, b)\n }\n\n if(map.contains(b))\n {\n map.put(b, Math.max(map.get(b)!!,a))\n }\n else\n {\n map.put(b, a)\n }\n }\n var count = 0\n for(x in arr)\n {\n if(map.containsKey(x))\n {\n if(x> map.get(x)!!)\n count++\n }\n else\n count++\n }\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1596640604, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02689/input.txt", "sample_output_relpath": "derived/input_output/data/p02689/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02689/Kotlin/s077830080.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s077830080", "user_id": "u801179767"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport kotlin.collections.ArrayList\nimport kotlin.collections.HashMap\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var (n,m) = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var arr = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n\n var map = HashMap()\n for(i in 1..m)\n {\n var (a,b) = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n\n if(map.contains(a))\n {\n map.put(a, Math.max(map.get(a)!!,b))\n }\n else\n {\n map.put(a, b)\n }\n\n if(map.contains(b))\n {\n map.put(b, Math.max(map.get(b)!!,a))\n }\n else\n {\n map.put(b, a)\n }\n }\n var count = 0\n for(x in arr)\n {\n if(map.containsKey(x))\n {\n if(x> map.get(x)!!)\n count++\n }\n else\n count++\n }\n println(count)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "sample_input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02689", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 997, "cpu_time_ms": 2208, "memory_kb": 75796}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s114124116", "group_id": "codeNet:p02689", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val h = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val g = Array>(n) { mutableSetOf() }\n repeat(m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt()-1 }\n g[a].add(b)\n g[b].add(a)\n }\n var ans = 0\n for (i in h.indices) {\n if (g[i].all { h[i] > h[it] }) ans++\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1588554949, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02689/input.txt", "sample_output_relpath": "derived/input_output/data/p02689/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02689/Kotlin/s114124116.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114124116", "user_id": "u506403362"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val h = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val g = Array>(n) { mutableSetOf() }\n repeat(m) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt()-1 }\n g[a].add(b)\n g[b].add(a)\n }\n var ans = 0\n for (i in h.indices) {\n if (g[i].all { h[i] > h[it] }) ans++\n }\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "sample_input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02689", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 428, "cpu_time_ms": 846, "memory_kb": 87112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s045922646", "group_id": "codeNet:p02690", "input_text": "import java.lang.Math.abs\n\nfun main(args: Array) = ABC166D.main()\n\nobject ABC166D {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n fun main() {\n val X = readInt()\n\n val (al, be) = (1..Int.MAX_VALUE).asSequence().mapNotNull { al ->\n val al2 = al * al\n val al4 = al2 * al2\n\n if (X % al != 0\n || ((X / al) - al4) % 5 != 0\n ) return@mapNotNull null\n\n if (al4 == X / al) return@mapNotNull al to 0\n\n val ga = ((X / al) - al4) / 5\n val s = if (ga == 0) 1 else abs(ga)\n val beta = (1..al).filter { ga % it == 0 }.asSequence()\n //.filter { b -> ga % b == 0 }\n .mapNotNull { pb ->\n val pLeft = al2 + pb\n val pRight = ga / pb\n\n val mb = -pb\n val mLeft = al2 + mb\n val mRight = ga / mb\n when {\n (pLeft == pRight) -> pb\n (mLeft == mRight) -> mb\n else -> null\n }\n }.firstOrNull()\n beta?.let { al to it }\n }.first()\n //////\n val D = Math.sqrt((al * al + 4 * be).toDouble()).toInt()\n val A1 = (al + D) / 2\n val A2 = (al - D) / 2\n val B1 = A1 - al\n val B2 = A2 - al\n val ans = when {\n check(A1, B1, X) -> A1 to B1\n check(A2, B2, X) -> A2 to B2\n else -> null\n }\n println(\"${ans?.first} ${ans?.second}\")\n }\n\n fun check(A: Int, B: Int, X: Int) = (A * A * A * A * A - B * B * B * B * B) == X\n\n /*####################################################################################*/\n\n fun readString() = readLine()!!\n fun readStrings() = readLine()!!.split(\" \")\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n fun readLong() = readLine()!!.toLong()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }\n\n fun Boolean.yesOrNo() = if (this) \"Yes\" else \"No\"\n fun Double.toNaturalExpr() = println(\"%f\".format(this))\n}", "language": "Kotlin", "metadata": {"date": 1588559057, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Kotlin/s045922646.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s045922646", "user_id": "u981616728"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "import java.lang.Math.abs\n\nfun main(args: Array) = ABC166D.main()\n\nobject ABC166D {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n fun main() {\n val X = readInt()\n\n val (al, be) = (1..Int.MAX_VALUE).asSequence().mapNotNull { al ->\n val al2 = al * al\n val al4 = al2 * al2\n\n if (X % al != 0\n || ((X / al) - al4) % 5 != 0\n ) return@mapNotNull null\n\n if (al4 == X / al) return@mapNotNull al to 0\n\n val ga = ((X / al) - al4) / 5\n val s = if (ga == 0) 1 else abs(ga)\n val beta = (1..al).filter { ga % it == 0 }.asSequence()\n //.filter { b -> ga % b == 0 }\n .mapNotNull { pb ->\n val pLeft = al2 + pb\n val pRight = ga / pb\n\n val mb = -pb\n val mLeft = al2 + mb\n val mRight = ga / mb\n when {\n (pLeft == pRight) -> pb\n (mLeft == mRight) -> mb\n else -> null\n }\n }.firstOrNull()\n beta?.let { al to it }\n }.first()\n //////\n val D = Math.sqrt((al * al + 4 * be).toDouble()).toInt()\n val A1 = (al + D) / 2\n val A2 = (al - D) / 2\n val B1 = A1 - al\n val B2 = A2 - al\n val ans = when {\n check(A1, B1, X) -> A1 to B1\n check(A2, B2, X) -> A2 to B2\n else -> null\n }\n println(\"${ans?.first} ${ans?.second}\")\n }\n\n fun check(A: Int, B: Int, X: Int) = (A * A * A * A * A - B * B * B * B * B) == X\n\n /*####################################################################################*/\n\n fun readString() = readLine()!!\n fun readStrings() = readLine()!!.split(\" \")\n fun readInt() = readLine()!!.toInt()\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n fun readLong() = readLine()!!.toLong()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }\n\n fun Boolean.yesOrNo() = if (this) \"Yes\" else \"No\"\n fun Double.toNaturalExpr() = println(\"%f\".format(this))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2288, "cpu_time_ms": 2207, "memory_kb": 55140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s467689142", "group_id": "codeNet:p02690", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val x = nextLong()\n\n for (a in -1000L..1000L) {\n for (b in -1000L..1000L) {\n val res = a * a * a * a * a - b * b * b * b * b\n if(res == x) {\n println(\"$a $b\")\n return\n }\n }\n }\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1588557656, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Kotlin/s467689142.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s467689142", "user_id": "u581625805"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val x = nextLong()\n\n for (a in -1000L..1000L) {\n for (b in -1000L..1000L) {\n val res = a * a * a * a * a - b * b * b * b * b\n if(res == x) {\n println(\"$a $b\")\n return\n }\n }\n }\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14454, "cpu_time_ms": 92, "memory_kb": 34608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s125444229", "group_id": "codeNet:p02691", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nfun main() {\n val N = rd.readInt()\n val A = rd.readIntArray()\n assert(A.size == N)\n\n // A[i]+A[j] == j - i\n // i + A[i] == j - A[j]\n\n val mp = mutableMapOf()\n\n var ans = 0L\n for (i in 0 until N) {\n ans += mp[i - A[i]] ?: 0\n mp[i+A[i]] = (mp[i+A[i]] ?: 0) + 1\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"166\", \"e\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "language": "Kotlin", "metadata": {"date": 1594524127, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Kotlin/s125444229.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s125444229", "user_id": "u404244809"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nfun main() {\n val N = rd.readInt()\n val A = rd.readIntArray()\n assert(A.size == N)\n\n // A[i]+A[j] == j - i\n // i + A[i] == j - A[j]\n\n val mp = mutableMapOf()\n\n var ans = 0L\n for (i in 0 until N) {\n ans += mp[i - A[i]] ?: 0\n mp[i+A[i]] = (mp[i+A[i]] ?: 0) + 1\n }\n\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"abc\", \"166\", \"e\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1704, "cpu_time_ms": 434, "memory_kb": 72264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s236466382", "group_id": "codeNet:p02691", "input_text": "import kotlin.math.abs\n\nfun main(args: Array) {\n\n val partyCount = readLine()!!.toInt()\n val persons = readLine()!!.split(\" \").map { it.toInt() }.mapIndexed { idx, it -> Person(idx+1, it) }\n\n process1(partyCount, persons)\n}\n\nclass Person(val index: Int, val height: Int)\n\nfun process1(personCount: Int, persons: List) {\n var count = 0\n for(person in persons) {\n for (buddy in persons) {\n if(person.index == buddy.index) {\n continue\n }\n if(abs(person.index - buddy.index) == (person.height + buddy.height)) {\n count++\n }\n }\n }\n if(count == 0) {\n print(0)\n } else {\n print(count / 2)\n }\n}", "language": "Kotlin", "metadata": {"date": 1589057236, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Kotlin/s236466382.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s236466382", "user_id": "u950770225"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import kotlin.math.abs\n\nfun main(args: Array) {\n\n val partyCount = readLine()!!.toInt()\n val persons = readLine()!!.split(\" \").map { it.toInt() }.mapIndexed { idx, it -> Person(idx+1, it) }\n\n process1(partyCount, persons)\n}\n\nclass Person(val index: Int, val height: Int)\n\nfun process1(personCount: Int, persons: List) {\n var count = 0\n for(person in persons) {\n for (buddy in persons) {\n if(person.index == buddy.index) {\n continue\n }\n if(abs(person.index - buddy.index) == (person.height + buddy.height)) {\n count++\n }\n }\n }\n if(count == 0) {\n print(0)\n } else {\n print(count / 2)\n }\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 732, "cpu_time_ms": 2208, "memory_kb": 65356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s538288056", "group_id": "codeNet:p02691", "input_text": "import kotlin.math.abs\nimport kotlin.math.pow\n\nfun main() {\n println(solve())\n}\n\nval solve: () -> Any = {\n val N = readInt()\n val A = readLongList()\n var res = 0\n\n val L = A\n .withIndex()\n .map { (i, v) -> i - v }\n .groupingBy { it }\n .eachCount()\n\n val R = A\n .withIndex()\n .map { (i, v) -> i + v }\n .groupingBy { it }\n .eachCount()\n\n L.map { (k, v) -> v * (R[k] ?: 0) }.sum()\n}\n\nval mod: Int = 1_000_000_007\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\n\nfun T.alsoPrintln() = also { println(this) }\n\nfun Boolean.toYesOrNo(yes: String = \"Yes\", no: String = \"No\") = if (this) yes else no", "language": "Kotlin", "metadata": {"date": 1588800963, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Kotlin/s538288056.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s538288056", "user_id": "u043557308"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import kotlin.math.abs\nimport kotlin.math.pow\n\nfun main() {\n println(solve())\n}\n\nval solve: () -> Any = {\n val N = readInt()\n val A = readLongList()\n var res = 0\n\n val L = A\n .withIndex()\n .map { (i, v) -> i - v }\n .groupingBy { it }\n .eachCount()\n\n val R = A\n .withIndex()\n .map { (i, v) -> i + v }\n .groupingBy { it }\n .eachCount()\n\n L.map { (k, v) -> v * (R[k] ?: 0) }.sum()\n}\n\nval mod: Int = 1_000_000_007\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\n\nfun T.alsoPrintln() = also { println(this) }\n\nfun Boolean.toYesOrNo(yes: String = \"Yes\", no: String = \"No\") = if (this) yes else no", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 907, "cpu_time_ms": 904, "memory_kb": 110692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s063901073", "group_id": "codeNet:p02691", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }\n\n var cnt = 0L\n\n aa.forEachIndexed { idx, h ->\n for (i in idx + h + 1 until n) {\n if ((i-idx) == h + aa[i]) cnt++\n }\n }\n\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1588556608, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Kotlin/s063901073.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s063901073", "user_id": "u262403099"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }\n\n var cnt = 0L\n\n aa.forEachIndexed { idx, h ->\n for (i in idx + h + 1 until n) {\n if ((i-idx) == h + aa[i]) cnt++\n }\n }\n\n println(cnt)\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 2208, "memory_kb": 66176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s749559105", "group_id": "codeNet:p02692", "input_text": "import java.io.PrintWriter\nimport kotlin.math.min\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n var (n, a, b, c) = readInputLine().split(\" \").map { it.toInt() }\n\n val query = Array(n) { readInputLine() }\n\n val builder = StringBuilder()\n\n builder.append(\"Yes\\n\")\n// pw.println(\"Yes\")\n\n for (i in 0 until n) {\n when(query[i]) {\n \"AB\" -> {\n if (a == 0 && b == 0) {\n println(\"No\")\n return\n }\n if (a < b || (a == 1 && b == 1 && query[min(i + 1, n - 1)] == \"AC\")) {\n// pw.println(\"A\")\n builder.append(\"A\\n\")\n a++\n b--\n } else {\n// pw.println(\"B\")\n builder.append(\"B\\n\")\n a--\n b++\n }\n }\n \"AC\" -> {\n if (a == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (a < c || (a == 1 && c == 1 && query[min(i + 1, n - 1)] == \"AB\")) {\n// pw.println(\"A\")\n builder.append(\"A\\n\")\n a++\n c--\n } else {\n// pw.println(\"C\")\n builder.append(\"C\\n\")\n a--\n c++\n }\n }\n \"BC\" -> {\n if (b == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (b < c || (b == 1 && c == 1 && query[min(i + 1, n - 1)] == \"AB\")) {\n// pw.println(\"B\")\n builder.append(\"B\\n\")\n b++\n c--\n } else {\n// pw.println(\"C\")\n builder.append(\"C\\n\")\n b--\n c++\n }\n }\n }\n }\n\n println(builder.toString())\n\n// pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1588669066, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/Kotlin/s749559105.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749559105", "user_id": "u505558493"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.min\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n var (n, a, b, c) = readInputLine().split(\" \").map { it.toInt() }\n\n val query = Array(n) { readInputLine() }\n\n val builder = StringBuilder()\n\n builder.append(\"Yes\\n\")\n// pw.println(\"Yes\")\n\n for (i in 0 until n) {\n when(query[i]) {\n \"AB\" -> {\n if (a == 0 && b == 0) {\n println(\"No\")\n return\n }\n if (a < b || (a == 1 && b == 1 && query[min(i + 1, n - 1)] == \"AC\")) {\n// pw.println(\"A\")\n builder.append(\"A\\n\")\n a++\n b--\n } else {\n// pw.println(\"B\")\n builder.append(\"B\\n\")\n a--\n b++\n }\n }\n \"AC\" -> {\n if (a == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (a < c || (a == 1 && c == 1 && query[min(i + 1, n - 1)] == \"AB\")) {\n// pw.println(\"A\")\n builder.append(\"A\\n\")\n a++\n c--\n } else {\n// pw.println(\"C\")\n builder.append(\"C\\n\")\n a--\n c++\n }\n }\n \"BC\" -> {\n if (b == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (b < c || (b == 1 && c == 1 && query[min(i + 1, n - 1)] == \"AB\")) {\n// pw.println(\"B\")\n builder.append(\"B\\n\")\n b++\n c--\n } else {\n// pw.println(\"C\")\n builder.append(\"C\\n\")\n b--\n c++\n }\n }\n }\n }\n\n println(builder.toString())\n\n// pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2107, "cpu_time_ms": 278, "memory_kb": 60852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s937177988", "group_id": "codeNet:p02692", "input_text": "import java.io.PrintWriter\nimport kotlin.math.min\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n var (n, a, b, c) = readInputLine().split(\" \").map { it.toInt() }\n\n val query = Array(n) { readInputLine() }\n\n pw.println(\"Yes\")\n\n for (i in 0 until n) {\n when(query[i]) {\n \"AB\" -> {\n if (a == 0 && b == 0) {\n println(\"No\")\n return\n }\n if (a == 0) {\n pw.println(\"A\")\n a++\n b--\n } else if (b == 0) {\n pw.println(\"B\")\n a--\n b++\n } else if (a == 1 && b == 1 && query[min(i + 1, n - 1)] != \"AB\") {\n if (query[min(i + 1, n - 1)] == \"AC\") {\n pw.println(\"A\")\n a++\n b--\n } else {\n pw.println(\"B\")\n a--\n b++\n }\n } else {\n pw.println(\"A\")\n a++\n b--\n }\n }\n \"AC\" -> {\n if (a == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (a == 0) {\n pw.println(\"A\")\n a++\n c--\n } else if (c == 0) {\n pw.println(\"C\")\n a--\n c++\n } else if (a == 1 && c == 1 && query[min(i + 1, n - 1)] != \"AC\") {\n if (query[min(i + 1, n - 1)] == \"AB\") {\n pw.println(\"A\")\n a++\n c--\n } else {\n pw.println(\"C\")\n a--\n c++\n }\n } else {\n pw.println(\"A\")\n a++\n c--\n }\n }\n \"BC\" -> {\n if (b == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (b == 0) {\n pw.println(\"B\")\n b++\n c--\n } else if (c == 0) {\n pw.println(\"C\")\n b--\n c++\n } else if (b == 1 && c == 1 && query[min(i + 1, n - 1)] != \"BC\") {\n if (query[min(i + 1, n - 1)] == \"AB\") {\n pw.println(\"B\")\n b++\n c--\n } else {\n pw.println(\"C\")\n b--\n c++\n }\n } else {\n pw.println(\"B\")\n b++\n c--\n }\n }\n }\n }\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1588540426, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/Kotlin/s937177988.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s937177988", "user_id": "u505558493"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.min\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n var (n, a, b, c) = readInputLine().split(\" \").map { it.toInt() }\n\n val query = Array(n) { readInputLine() }\n\n pw.println(\"Yes\")\n\n for (i in 0 until n) {\n when(query[i]) {\n \"AB\" -> {\n if (a == 0 && b == 0) {\n println(\"No\")\n return\n }\n if (a == 0) {\n pw.println(\"A\")\n a++\n b--\n } else if (b == 0) {\n pw.println(\"B\")\n a--\n b++\n } else if (a == 1 && b == 1 && query[min(i + 1, n - 1)] != \"AB\") {\n if (query[min(i + 1, n - 1)] == \"AC\") {\n pw.println(\"A\")\n a++\n b--\n } else {\n pw.println(\"B\")\n a--\n b++\n }\n } else {\n pw.println(\"A\")\n a++\n b--\n }\n }\n \"AC\" -> {\n if (a == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (a == 0) {\n pw.println(\"A\")\n a++\n c--\n } else if (c == 0) {\n pw.println(\"C\")\n a--\n c++\n } else if (a == 1 && c == 1 && query[min(i + 1, n - 1)] != \"AC\") {\n if (query[min(i + 1, n - 1)] == \"AB\") {\n pw.println(\"A\")\n a++\n c--\n } else {\n pw.println(\"C\")\n a--\n c++\n }\n } else {\n pw.println(\"A\")\n a++\n c--\n }\n }\n \"BC\" -> {\n if (b == 0 && c == 0) {\n println(\"No\")\n return\n }\n if (b == 0) {\n pw.println(\"B\")\n b++\n c--\n } else if (c == 0) {\n pw.println(\"C\")\n b--\n c++\n } else if (b == 1 && c == 1 && query[min(i + 1, n - 1)] != \"BC\") {\n if (query[min(i + 1, n - 1)] == \"AB\") {\n pw.println(\"B\")\n b++\n c--\n } else {\n pw.println(\"C\")\n b--\n c++\n }\n } else {\n pw.println(\"B\")\n b++\n c--\n }\n }\n }\n }\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3093, "cpu_time_ms": 331, "memory_kb": 63884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s043557237", "group_id": "codeNet:p02693", "input_text": "fun main() {\n val k = readLine()!!.toInt()\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = \"OK\"\n val aa = a % k\n val bb = b % k\n if ( b - a < k) {\n if (a == 0 || b == 0) {\n\n } else {\n if (a < b){\n ans = \"NG\"\n }\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1595569347, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02693/input.txt", "sample_output_relpath": "derived/input_output/data/p02693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02693/Kotlin/s043557237.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s043557237", "user_id": "u945228737"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "fun main() {\n val k = readLine()!!.toInt()\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n var ans = \"OK\"\n val aa = a % k\n val bb = b % k\n if ( b - a < k) {\n if (a == 0 || b == 0) {\n\n } else {\n if (a < b){\n ans = \"NG\"\n }\n }\n }\n println(ans)\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 116, "memory_kb": 36424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s409750460", "group_id": "codeNet:p02693", "input_text": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val k = readInteger()\n val (a, b) = readIntegerList()\n for (i in a..b) {\n if (i % k == 0) {\n println(\"OK\")\n return\n }\n }\n println(\"NG\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1589150529, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02693/input.txt", "sample_output_relpath": "derived/input_output/data/p02693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02693/Kotlin/s409750460.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s409750460", "user_id": "u784448849"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val k = readInteger()\n val (a, b) = readIntegerList()\n for (i in a..b) {\n if (i % k == 0) {\n println(\"OK\")\n return\n }\n }\n println(\"NG\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 677, "cpu_time_ms": 100, "memory_kb": 36588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s273031683", "group_id": "codeNet:p02693", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val k = nextLong()\n val a = nextLong()\n val b = nextLong()\n\n for (i in a..b) {\n if(i % k == 0L) {\n println(\"OK\")\n return\n }\n }\n\n println(\"NG\")\n\n\n\n}\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1588468314, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02693/input.txt", "sample_output_relpath": "derived/input_output/data/p02693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02693/Kotlin/s273031683.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273031683", "user_id": "u581625805"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val k = nextLong()\n val a = nextLong()\n val b = nextLong()\n\n for (i in a..b) {\n if(i % k == 0L) {\n println(\"OK\")\n return\n }\n }\n\n println(\"NG\")\n\n\n\n}\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14389, "cpu_time_ms": 115, "memory_kb": 34668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s335311115", "group_id": "codeNet:p02694", "input_text": "fun main(args: Array) {\n var x = readLine()!!.toInt()\n var i = 0\n var n = 100\n while (n < x) {\n n = (n*1.01).toInt()\n i ++\n }\n println(i)\n}", "language": "Kotlin", "metadata": {"date": 1588493170, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Kotlin/s335311115.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s335311115", "user_id": "u906501980"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n var x = readLine()!!.toInt()\n var i = 0\n var n = 100\n while (n < x) {\n n = (n*1.01).toInt()\n i ++\n }\n println(i)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 179, "cpu_time_ms": 81, "memory_kb": 34488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s434787254", "group_id": "codeNet:p02695", "input_text": "var a: Array = arrayOf()\nvar b: Array = arrayOf()\nvar c: Array = arrayOf()\nvar d: Array = arrayOf()\n\nfun main() {\n val l = readLine()!!.split(' ').map { it.toInt() }\n a = Array(l[2]) { 0 }\n b = Array(l[2]) { 0 }\n c = Array(l[2]) { 0 }\n d = Array(l[2]) { 0 }\n for (i in 0 until l[2]) {\n val line = readLine()!!.split(' ').map { it.toInt() }\n a[i] = line[0]-1\n b[i] = line[1]-1\n c[i] = line[2]\n d[i] = line[3]\n }\n var arr = Array(l[0]) { 1 }\n var max = 0\n for (s in l[0]-1 downTo 0) {\n for (t in 1..l[1]) {\n arr[s] = t\n max = Math.max(max, eval(arr))\n }\n }\n println(max)\n}\n\nfun eval(arr: Array): Int {\n var res = 0\n for (x in 0 until a.size) {\n if (arr[b[x]]-arr[a[x]] == c[x]) {\n res += d[x]\n }\n }\n return res\n}\n", "language": "Kotlin", "metadata": {"date": 1588537943, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Kotlin/s434787254.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s434787254", "user_id": "u213256030"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "var a: Array = arrayOf()\nvar b: Array = arrayOf()\nvar c: Array = arrayOf()\nvar d: Array = arrayOf()\n\nfun main() {\n val l = readLine()!!.split(' ').map { it.toInt() }\n a = Array(l[2]) { 0 }\n b = Array(l[2]) { 0 }\n c = Array(l[2]) { 0 }\n d = Array(l[2]) { 0 }\n for (i in 0 until l[2]) {\n val line = readLine()!!.split(' ').map { it.toInt() }\n a[i] = line[0]-1\n b[i] = line[1]-1\n c[i] = line[2]\n d[i] = line[3]\n }\n var arr = Array(l[0]) { 1 }\n var max = 0\n for (s in l[0]-1 downTo 0) {\n for (t in 1..l[1]) {\n arr[s] = t\n max = Math.max(max, eval(arr))\n }\n }\n println(max)\n}\n\nfun eval(arr: Array): Int {\n var res = 0\n for (x in 0 until a.size) {\n if (arr[b[x]]-arr[a[x]] == c[x]) {\n res += d[x]\n }\n }\n return res\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 880, "cpu_time_ms": 158, "memory_kb": 37744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s847195604", "group_id": "codeNet:p02695", "input_text": "import java.io.PrintWriter\nimport kotlin.math.max\n\ndata class Query(val a: Int, val b: Int, val c: Int, val d: Int)\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n val (n, m, q) = readInputLine().split(\" \").map { it.toInt() }\n\n val query = Array(q) { Query(0, 0, 0, 0) }\n\n repeat(q) {\n val input = readInputLine().split(\" \").map { it.toInt() }\n query[it] = Query(input[0] - 1, input[1] - 1, input[2], input[3])\n }\n\n val arr = IntArray(n) { 1 }\n\n fun dfs(index: Int, min: Int): Int {\n if (index == n) {\n var ret = 0\n for (qe in query) {\n if (arr[qe.b] - arr[qe.a] == qe.c) {\n ret += qe.d\n }\n }\n return ret\n }\n\n var ret = 0\n\n for (i in min..m) {\n arr[index] = i\n ret = max(ret, dfs(index + 1, i))\n }\n\n return ret\n }\n\n pw.println(dfs(1, 1))\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\n// これが全探索で計算量的に問題ないと見抜けないの、数学的素養がなさすぎてつらい\n// 競プロ向いていない つらい\n", "language": "Kotlin", "metadata": {"date": 1588523339, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Kotlin/s847195604.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s847195604", "user_id": "u505558493"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.max\n\ndata class Query(val a: Int, val b: Int, val c: Int, val d: Int)\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n val (n, m, q) = readInputLine().split(\" \").map { it.toInt() }\n\n val query = Array(q) { Query(0, 0, 0, 0) }\n\n repeat(q) {\n val input = readInputLine().split(\" \").map { it.toInt() }\n query[it] = Query(input[0] - 1, input[1] - 1, input[2], input[3])\n }\n\n val arr = IntArray(n) { 1 }\n\n fun dfs(index: Int, min: Int): Int {\n if (index == n) {\n var ret = 0\n for (qe in query) {\n if (arr[qe.b] - arr[qe.a] == qe.c) {\n ret += qe.d\n }\n }\n return ret\n }\n\n var ret = 0\n\n for (i in min..m) {\n arr[index] = i\n ret = max(ret, dfs(index + 1, i))\n }\n\n return ret\n }\n\n pw.println(dfs(1, 1))\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\n// これが全探索で計算量的に問題ないと見抜けないの、数学的素養がなさすぎてつらい\n// 競プロ向いていない つらい\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1173, "cpu_time_ms": 153, "memory_kb": 38808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s351144679", "group_id": "codeNet:p02695", "input_text": "fun main(args: Array) {\n val (n,m,q) = readLine()!!.split(\" \").map(String::toInt)\n var result = 0\n\n val value = Array(q){\n readLine()!!.split(\" \").map{it.toInt()}\n }\n\n var list = Array(n){1}\n\n loop@ while(true){\n\n var sum = 0\n value.forEach {\n if(list[it[1] - 1] - list[it[0] - 1] == it[2]){\n sum += it[3]\n }\n } \n if(sum > result){\n result = sum\n }\n\n for(i in list.indices){\n if(i == list.size - 1 && list[list.size-1] < m){\n list[list.size-1] += 1\n continue@loop\n }else if(list[i + 1] == m){\n for (k in i+1 until list.size){\n list[k] = 2\n }\n list[i] += 1\n continue@loop\n }else if(list[0] == m){\n break@loop\n }\n }\n }\n\n println(\"${result}\")\n}", "language": "Kotlin", "metadata": {"date": 1588473798, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Kotlin/s351144679.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s351144679", "user_id": "u862494256"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,m,q) = readLine()!!.split(\" \").map(String::toInt)\n var result = 0\n\n val value = Array(q){\n readLine()!!.split(\" \").map{it.toInt()}\n }\n\n var list = Array(n){1}\n\n loop@ while(true){\n\n var sum = 0\n value.forEach {\n if(list[it[1] - 1] - list[it[0] - 1] == it[2]){\n sum += it[3]\n }\n } \n if(sum > result){\n result = sum\n }\n\n for(i in list.indices){\n if(i == list.size - 1 && list[list.size-1] < m){\n list[list.size-1] += 1\n continue@loop\n }else if(list[i + 1] == m){\n for (k in i+1 until list.size){\n list[k] = 2\n }\n list[i] += 1\n continue@loop\n }else if(list[0] == m){\n break@loop\n }\n }\n }\n\n println(\"${result}\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 952, "cpu_time_ms": 2207, "memory_kb": 54588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s747220575", "group_id": "codeNet:p02695", "input_text": "import java.util.*\n\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val q = sc.nextInt()\n\n data class ABCD(val a: Int, val b: Int, val c: Int, val d: Int)\n\n val tuples = Array(q) { ABCD(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()) }\n\n var maxSums = 0L\n for (listA in getAs(n, m)) {\n var sum = 0L\n for ((a, b, c, d) in tuples) {\n if (listA[b-1] - listA[a-1] == c)\n sum += d\n }\n maxSums = maxOf(maxSums, sum)\n }\n\n println(maxSums)\n}\n\nfun getAs(n: Int, m: Int) = sequence {\n fun a(prev: Int): IntRange {\n return (prev) .. (m)\n }\n fun b(ary: IntArray, dims: Int): Sequence = sequence {\n if (dims == 0) yield(ary)\n else {\n for (v in a(ary.getOrNull(ary.size - dims - 1) ?: 0)) {\n ary[ary.size - dims] = v\n yieldAll(b(ary, dims - 1))\n }\n }\n }\n yieldAll(b(IntArray(n), n))\n}", "language": "Kotlin", "metadata": {"date": 1588471728, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Kotlin/s747220575.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s747220575", "user_id": "u466955962"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import java.util.*\n\n\nfun main() {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val q = sc.nextInt()\n\n data class ABCD(val a: Int, val b: Int, val c: Int, val d: Int)\n\n val tuples = Array(q) { ABCD(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()) }\n\n var maxSums = 0L\n for (listA in getAs(n, m)) {\n var sum = 0L\n for ((a, b, c, d) in tuples) {\n if (listA[b-1] - listA[a-1] == c)\n sum += d\n }\n maxSums = maxOf(maxSums, sum)\n }\n\n println(maxSums)\n}\n\nfun getAs(n: Int, m: Int) = sequence {\n fun a(prev: Int): IntRange {\n return (prev) .. (m)\n }\n fun b(ary: IntArray, dims: Int): Sequence = sequence {\n if (dims == 0) yield(ary)\n else {\n for (v in a(ary.getOrNull(ary.size - dims - 1) ?: 0)) {\n ary[ary.size - dims] = v\n yieldAll(b(ary, dims - 1))\n }\n }\n }\n yieldAll(b(IntArray(n), n))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1019, "cpu_time_ms": 305, "memory_kb": 58704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s647293751", "group_id": "codeNet:p02696", "input_text": "fun main(args: Array) {\n val input = readLine()!!.split(\" \")\n val a = input[0].toDouble()\n val b = input[1].toDouble()\n val n = input[2].toLong()\n\n val result = LongRange(1, n).map { Math.floor(a * it / b) - a * Math.floor(it / b) }.max() ?: 0.0\n print(result.toInt())\n}", "language": "Kotlin", "metadata": {"date": 1590945719, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s647293751.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s647293751", "user_id": "u950770225"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()!!.split(\" \")\n val a = input[0].toDouble()\n val b = input[1].toDouble()\n val n = input[2].toLong()\n\n val result = LongRange(1, n).map { Math.floor(a * it / b) - a * Math.floor(it / b) }.max() ?: 0.0\n print(result.toInt())\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 2225, "memory_kb": 808336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s990775053", "group_id": "codeNet:p02696", "input_text": "fun main(args: Array) {\n val (a, b, n) = readLine()!!.split(\" \").map(String::toInt)\n val max = mutableMapOf()\n for (i in 1..n) {\n val r = Math.floor(((a * i) / b).toDouble()) + Math.floor((i / b).toDouble())\n max[i] = r\n }\n\n max.maxBy {\n it.value\n }?.let {\n val r = it.value.toInt()\n println(r)\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1588523465, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s990775053.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s990775053", "user_id": "u228849856"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, n) = readLine()!!.split(\" \").map(String::toInt)\n val max = mutableMapOf()\n for (i in 1..n) {\n val r = Math.floor(((a * i) / b).toDouble()) + Math.floor((i / b).toDouble())\n max[i] = r\n }\n\n max.maxBy {\n it.value\n }?.let {\n val r = it.value.toInt()\n println(r)\n }\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 377, "cpu_time_ms": 124, "memory_kb": 38152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s167950223", "group_id": "codeNet:p02696", "input_text": "import kotlin.math.floor\n\nfun main(){\n val (a, b, n) = readLine()!!.split(\" \").map { it.toLong() }\n var hikaku = 0.toLong()\n if (n >= b) hikaku = b - 1\n else hikaku = n\n var x = hikaku * a / b\n println(x)\n\n}", "language": "Kotlin", "metadata": {"date": 1588476052, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s167950223.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167950223", "user_id": "u385678999"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.floor\n\nfun main(){\n val (a, b, n) = readLine()!!.split(\" \").map { it.toLong() }\n var hikaku = 0.toLong()\n if (n >= b) hikaku = b - 1\n else hikaku = n\n var x = hikaku * a / b\n println(x)\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 225, "cpu_time_ms": 98, "memory_kb": 36376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s596823934", "group_id": "codeNet:p02696", "input_text": "fun main(args: Array) {\n val (a, b, n) = readLine()!!.split(' ').map { it.toLong() }\n\n fun calc(a: Long, b:Long, x:Long):Long {\n val ad = a.toDouble()\n val bd = b.toDouble()\n val xd = x.toDouble()\n val ret = (Math.floor(ad * xd / bd) - ad * Math.floor(xd / bd)).toLong()\n return ret\n }\n\n var l = 0L\n var r = n\n var m = ((l-1)+(r+1))/2\n var max = Math.max(calc(a,b,l),calc(a,b,r))\n while (r-l > 1) {\n val ll = calc(a,b,l)\n val lll = calc(a,b,(l+m)/2)\n val rr = calc(a,b,r)\n val rrr = calc(a,b,(m+r)/2)\n max = Math.max(max, Math.max(Math.max(ll,rr), Math.max(lll,rrr)))\n if (lll > rrr) {\n r = m\n } else if (ll <= rr) {\n l = m\n }\n m = (l+r)/2\n }\n println(max)\n}\n", "language": "Kotlin", "metadata": {"date": 1588474012, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s596823934.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s596823934", "user_id": "u288435405"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, n) = readLine()!!.split(' ').map { it.toLong() }\n\n fun calc(a: Long, b:Long, x:Long):Long {\n val ad = a.toDouble()\n val bd = b.toDouble()\n val xd = x.toDouble()\n val ret = (Math.floor(ad * xd / bd) - ad * Math.floor(xd / bd)).toLong()\n return ret\n }\n\n var l = 0L\n var r = n\n var m = ((l-1)+(r+1))/2\n var max = Math.max(calc(a,b,l),calc(a,b,r))\n while (r-l > 1) {\n val ll = calc(a,b,l)\n val lll = calc(a,b,(l+m)/2)\n val rr = calc(a,b,r)\n val rrr = calc(a,b,(m+r)/2)\n max = Math.max(max, Math.max(Math.max(ll,rr), Math.max(lll,rrr)))\n if (lll > rrr) {\n r = m\n } else if (ll <= rr) {\n l = m\n }\n m = (l+r)/2\n }\n println(max)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 817, "cpu_time_ms": 2207, "memory_kb": 42864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s858702967", "group_id": "codeNet:p02696", "input_text": "fun main(args: Array) {\n val (a, b, n) = readLine()!!.split(' ').map { it.toLong() }\n\n fun calc(a: Long, b:Long, x:Long):Long {\n val ad = a.toDouble()\n val bd = b.toDouble()\n val xd = x.toDouble()\n val ret = (Math.floor(ad * xd / bd) - ad * Math.floor(xd / bd)).toLong()\n return ret\n }\n\n fun search(li: Long, ri:Long):Long {\n var l = li\n var r = ri\n var m = ((l-1)+(r+1))/2\n var max = Math.max(calc(a,b,l),calc(a,b,r))\n while (r-l > 0) {\n val c = calc(a,b,m)\n val ll = calc(a,b,(l+m)/2)\n val rr = calc(a,b,(m+r)/2)\n max = Math.max(max, Math.max(Math.max(ll,rr),c))\n if (ll > rr) {\n r = m\n } else if (ll < rr) {\n l = m\n } else break\n m = (l+r)/2\n }\n return max\n }\n val l = 0L\n val r = n\n val m = ((l-1)+(r+1))/2\n var max = search(l,r)\n max = Math.max(max, search(l,m))\n max = Math.max(max, search(m,r))\n println(max)\n}\n", "language": "Kotlin", "metadata": {"date": 1588473017, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s858702967.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s858702967", "user_id": "u288435405"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, n) = readLine()!!.split(' ').map { it.toLong() }\n\n fun calc(a: Long, b:Long, x:Long):Long {\n val ad = a.toDouble()\n val bd = b.toDouble()\n val xd = x.toDouble()\n val ret = (Math.floor(ad * xd / bd) - ad * Math.floor(xd / bd)).toLong()\n return ret\n }\n\n fun search(li: Long, ri:Long):Long {\n var l = li\n var r = ri\n var m = ((l-1)+(r+1))/2\n var max = Math.max(calc(a,b,l),calc(a,b,r))\n while (r-l > 0) {\n val c = calc(a,b,m)\n val ll = calc(a,b,(l+m)/2)\n val rr = calc(a,b,(m+r)/2)\n max = Math.max(max, Math.max(Math.max(ll,rr),c))\n if (ll > rr) {\n r = m\n } else if (ll < rr) {\n l = m\n } else break\n m = (l+r)/2\n }\n return max\n }\n val l = 0L\n val r = n\n val m = ((l-1)+(r+1))/2\n var max = search(l,r)\n max = Math.max(max, search(l,m))\n max = Math.max(max, search(m,r))\n println(max)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1064, "cpu_time_ms": 101, "memory_kb": 36368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s271159407", "group_id": "codeNet:p02696", "input_text": "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 n = sc.nextInt()\n\n println(abc165d(a, b, n))\n}\n\nprivate fun abc165d(a: Int, b: Int, n: Int): Int {\n var ans = Int.MIN_VALUE\n for (i in 1..n) {\n val tmp = Math.floor(((a * i)/b).toDouble()) - 5 * Math.floor((i/b).toDouble())\n if (tmp > ans) ans = tmp.toInt()\n }\n\n return ans\n}\n", "language": "Kotlin", "metadata": {"date": 1588472891, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s271159407.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s271159407", "user_id": "u323522006"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "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 n = sc.nextInt()\n\n println(abc165d(a, b, n))\n}\n\nprivate fun abc165d(a: Int, b: Int, n: Int): Int {\n var ans = Int.MIN_VALUE\n for (i in 1..n) {\n val tmp = Math.floor(((a * i)/b).toDouble()) - 5 * Math.floor((i/b).toDouble())\n if (tmp > ans) ans = tmp.toInt()\n }\n\n return ans\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 423, "cpu_time_ms": 112, "memory_kb": 36472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s940899684", "group_id": "codeNet:p02696", "input_text": "import java.io.PrintWriter\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n val (a, b, n) = readInputLine().split(\" \").map { it.toLong() }\n\n pw.println(a * n / b - a * (n / b))\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1588470851, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Kotlin/s940899684.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s940899684", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main() {\n val pw = PrintWriter(System.out)\n\n val (a, b, n) = readInputLine().split(\" \").map { it.toLong() }\n\n pw.println(a * n / b - a * (n / b))\n\n pw.flush()\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 96, "memory_kb": 36356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s295261153", "group_id": "codeNet:p02697", "input_text": "fun main() {\n val builder = StringBuilder()\n\n val (n, m) = readInputLine().split(\" \").map { it.toInt() }\n\n var diff = 0\n\n for (i in n / 2 downTo n / 2 - m + 1) {\n if ((i and 1) == 1) {\n builder.appendln(\"${1 + diff} ${1 + diff + i}\")\n } else {\n builder.appendln(\"${n - diff - i} ${n - diff}\")\n diff++\n }\n }\n\n print(builder.toString())\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1590845099, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/Kotlin/s295261153.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s295261153", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "fun main() {\n val builder = StringBuilder()\n\n val (n, m) = readInputLine().split(\" \").map { it.toInt() }\n\n var diff = 0\n\n for (i in n / 2 downTo n / 2 - m + 1) {\n if ((i and 1) == 1) {\n builder.appendln(\"${1 + diff} ${1 + diff + i}\")\n } else {\n builder.appendln(\"${n - diff - i} ${n - diff}\")\n diff++\n }\n }\n\n print(builder.toString())\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 466, "cpu_time_ms": 197, "memory_kb": 51628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s110614524", "group_id": "codeNet:p02699", "input_text": "fun main() {\n val (s, w) = readLine()!!.split(\" \").map { it.toInt() }\n if (s <= w) {\n println(\"unsafe\")\n } else {\n println(\"safe\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1587949319, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02699/input.txt", "sample_output_relpath": "derived/input_output/data/p02699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02699/Kotlin/s110614524.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s110614524", "user_id": "u897579945"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "fun main() {\n val (s, w) = readLine()!!.split(\" \").map { it.toInt() }\n if (s <= w) {\n println(\"unsafe\")\n } else {\n println(\"safe\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "sample_input": "4 5\n"}, "reference_outputs": ["unsafe\n"], "source_document_id": "p02699", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 161, "cpu_time_ms": 102, "memory_kb": 36440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s652145099", "group_id": "codeNet:p02706", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val m = readInt()\n val A = readIntArray(m)\n\n var ans = n - A.sum()\n if(ans < 0) ans = -1\n println(ans)\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _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}", "language": "Kotlin", "metadata": {"date": 1587392625, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/Kotlin/s652145099.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s652145099", "user_id": "u596111103"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n\nimport java.io.PrintWriter\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val n = readInt()\n val m = readInt()\n val A = readIntArray(m)\n\n var ans = n - A.sum()\n if(ans < 0) ans = -1\n println(ans)\n}\n\n/** IO code start */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\n@JvmField val _reader = INPUT.bufferedReader()\nfun readLine(): String? = _reader.readLine()\nfun readLn() = _reader.readLine()!!\n@JvmField var _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}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3547, "cpu_time_ms": 123, "memory_kb": 40520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s528291701", "group_id": "codeNet:p02706", "input_text": "fun main(args: Array) {\n val (numberOfSummerHolidays, numberOfHomeWorks) = readLine()!!.split(\" \").map{ it.toInt() }\n val homeworkCosts = readLine()!!.split(\" \").map { it.toInt() }\n val sumOfHomeworkCost = homeworkCosts.sum()\n\n if (numberOfSummerHolidays >= sumOfHomeworkCost) {\n println(numberOfSummerHolidays - sumOfHomeworkCost)\n } else {\n println(-1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1587345700, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/Kotlin/s528291701.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528291701", "user_id": "u605053892"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "fun main(args: Array) {\n val (numberOfSummerHolidays, numberOfHomeWorks) = readLine()!!.split(\" \").map{ it.toInt() }\n val homeworkCosts = readLine()!!.split(\" \").map { it.toInt() }\n val sumOfHomeworkCost = homeworkCosts.sum()\n\n if (numberOfSummerHolidays >= sumOfHomeworkCost) {\n println(numberOfSummerHolidays - sumOfHomeworkCost)\n } else {\n println(-1)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 170, "memory_kb": 39372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s041072055", "group_id": "codeNet:p02706", "input_text": "fun main(args: Array) {\n val n = readLine()!!.split(\" \").map { it.toInt() }[0]\n val sum = readLine()!!.split(\" \").map { it.toInt() }.sum()\n if (n < sum) {\n println(-1)\n } else {\n println(n-sum)\n }\n}", "language": "Kotlin", "metadata": {"date": 1587345164, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/Kotlin/s041072055.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s041072055", "user_id": "u213256030"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.split(\" \").map { it.toInt() }[0]\n val sum = readLine()!!.split(\" \").map { it.toInt() }.sum()\n if (n < sum) {\n println(-1)\n } else {\n println(n-sum)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 169, "memory_kb": 39360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s800309187", "group_id": "codeNet:p02706", "input_text": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n\n val sum = a.sum()\n\n when {\n n >= sum -> println(n - sum)\n else -> println(-1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1587344929, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/Kotlin/s800309187.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s800309187", "user_id": "u693548378"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "fun main() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n\n val sum = a.sum()\n\n when {\n n >= sum -> println(n - sum)\n else -> println(-1)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 207, "memory_kb": 39380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s809982524", "group_id": "codeNet:p02707", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val sum = MutableList(n) { 0 }\n a.map { sum[it-1]++ }\n sum.forEach { println(it) }\n}\n", "language": "Kotlin", "metadata": {"date": 1592156941, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02707.html", "problem_id": "p02707", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02707/input.txt", "sample_output_relpath": "derived/input_output/data/p02707/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02707/Kotlin/s809982524.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s809982524", "user_id": "u172820018"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val sum = MutableList(n) { 0 }\n a.map { sum[it-1]++ }\n sum.forEach { println(it) }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "sample_input": "5\n1 1 2 2\n"}, "reference_outputs": ["2\n2\n0\n0\n0\n"], "source_document_id": "p02707", "source_text": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 1145, "memory_kb": 70048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s664413536", "group_id": "codeNet:p02707", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n\n val a = readLine()!!.split(\" \").map(String::toInt).sorted()\n\n\n for(i in 1 .. n){\n println(\"${a.count { it == i }}\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1588550277, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02707.html", "problem_id": "p02707", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02707/input.txt", "sample_output_relpath": "derived/input_output/data/p02707/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02707/Kotlin/s664413536.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s664413536", "user_id": "u862494256"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n\n val a = readLine()!!.split(\" \").map(String::toInt).sorted()\n\n\n for(i in 1 .. n){\n println(\"${a.count { it == i }}\")\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "sample_input": "5\n1 1 2 2\n"}, "reference_outputs": ["2\n2\n0\n0\n0\n"], "source_document_id": "p02707", "source_text": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 184, "cpu_time_ms": 2207, "memory_kb": 66952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s453905587", "group_id": "codeNet:p02708", "input_text": "import java.io.PrintWriter\n\n//private val inp = java.io.File(\"in\")\nprivate val inp = System.`in`\nprivate val reader = inp.bufferedReader()\nprivate val wr = PrintWriter(System.out.bufferedWriter())\n\nprivate fun readLn(): String = reader.readLine()\nprivate fun readInt(): Int = readLn().toInt()\nprivate fun readStrs(): List = readLn().split(\" \")\nprivate fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()\nprivate fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()\n\nfun main() {\n val (n, k) = readInts()\n val pref = LongArray(n + 2)\n val mod = 1e9 + 7\n for (i in 1..n + 1) {\n pref[i] += pref[i - 1] + i - 1\n }\n\n var ans = 0L\n for (i in k..n + 1) {\n val minSum = pref[i]\n val maxSum = pref[n + 1] - pref[n + 1 - i]\n ans += maxSum - minSum + 1\n ans = (ans % mod).toLong()\n }\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1587444792, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02708.html", "problem_id": "p02708", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02708/input.txt", "sample_output_relpath": "derived/input_output/data/p02708/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02708/Kotlin/s453905587.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453905587", "user_id": "u366116119"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io.PrintWriter\n\n//private val inp = java.io.File(\"in\")\nprivate val inp = System.`in`\nprivate val reader = inp.bufferedReader()\nprivate val wr = PrintWriter(System.out.bufferedWriter())\n\nprivate fun readLn(): String = reader.readLine()\nprivate fun readInt(): Int = readLn().toInt()\nprivate fun readStrs(): List = readLn().split(\" \")\nprivate fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()\nprivate fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()\n\nfun main() {\n val (n, k) = readInts()\n val pref = LongArray(n + 2)\n val mod = 1e9 + 7\n for (i in 1..n + 1) {\n pref[i] += pref[i - 1] + i - 1\n }\n\n var ans = 0L\n for (i in k..n + 1) {\n val minSum = pref[i]\n val maxSum = pref[n + 1] - pref[n + 1 - i]\n ans += maxSum - minSum + 1\n ans = (ans % mod).toLong()\n }\n\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02708", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 899, "cpu_time_ms": 107, "memory_kb": 38044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s675062897", "group_id": "codeNet:p02709", "input_text": "import java.lang.Math.abs\n\nfun main(args: Array) = ABC163E.main()\n\nobject ABC163E {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n data class Problem(val items: List, val lefts: Set, val rights: Set) {\n val minPos: Int get() = lefts.size\n val maxPos: Int get() = lefts.size + items.size - 1\n fun getOneChoice(): Long? {\n return when {\n items.isEmpty() -> 0L\n else -> null\n }\n }\n\n override fun toString(): String {\n return \"${lefts.joinToString(\" \") { it.value.toString() }}|${\n items.sortedBy { it.pos }.joinToString(\" \") { it.value.toString() }\n }|${rights.reversed().joinToString(\" \") { it.value.toString() }}\"\n }\n\n override fun hashCode(): Int {\n var result = items.size\n result = 31 * result + lefts.size\n result = 31 * result + rights.size\n return result\n }\n }\n\n\n fun main() {\n val N = readInt()\n val A = readLongs()\n\n val items = A.mapIndexed { index, it -> Infant(pos = index, value = it) }\n .sortedByDescending { it.value }\n //log(items.joinToString(\"\\n\"))\n\n val table = LazyMap { problem ->\n problem.getOneChoice() ?: problem.let {\n val infant = it.items.first()\n // generate subProblem\n val left = Problem(\n items = it.items.drop(1),\n lefts = it.lefts + infant,\n rights = it.rights\n )\n val right = Problem(\n items = it.items.drop(1),\n lefts = it.lefts,\n rights = it.rights + infant\n )\n\n // generate choices\n val leftValue = get(left) + infant.value * abs(infant.pos - it.minPos)\n val rightValue = get(right) + infant.value * abs(it.maxPos - infant.pos)\n\n // evaluate choices\n val value = if (leftValue < rightValue) rightValue else leftValue\n //log(\"$it = $value\")\n value\n }\n }\n val ans = table[Problem(items = items, lefts = emptySet(), rights = emptySet())]\n println(ans)\n }\n\n\n /*####################################################################################*/\n data class Infant(val pos: Int, val value: Long)\n\n fun readInt() = readLine()!!.toInt()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n\n class LazyMap(private val init: LazyMap.(K) -> V) : Map {\n private val memo = HashMap()\n override fun get(key: K): V {\n return memo[key] ?: init(key).memorizingAt(key)\n }\n\n\n private fun V.memorizingAt(key: K): V {\n memo[key] = this\n return this\n }\n\n override val entries: Set>\n get() = memo.entries\n override val keys: Set\n get() = memo.keys\n override val size: Int\n get() = memo.size\n override val values: Collection\n get() = memo.values\n\n override fun containsKey(key: K): Boolean = memo.containsKey(key)\n override fun containsValue(value: V): Boolean = memo.containsValue(value)\n override fun isEmpty(): Boolean = memo.isEmpty()\n }\n}", "language": "Kotlin", "metadata": {"date": 1587357548, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02709.html", "problem_id": "p02709", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02709/input.txt", "sample_output_relpath": "derived/input_output/data/p02709/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02709/Kotlin/s675062897.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s675062897", "user_id": "u981616728"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "import java.lang.Math.abs\n\nfun main(args: Array) = ABC163E.main()\n\nobject ABC163E {\n fun log(message: Any?) {\n println(message)// TODO: ←消す\n }\n\n data class Problem(val items: List, val lefts: Set, val rights: Set) {\n val minPos: Int get() = lefts.size\n val maxPos: Int get() = lefts.size + items.size - 1\n fun getOneChoice(): Long? {\n return when {\n items.isEmpty() -> 0L\n else -> null\n }\n }\n\n override fun toString(): String {\n return \"${lefts.joinToString(\" \") { it.value.toString() }}|${\n items.sortedBy { it.pos }.joinToString(\" \") { it.value.toString() }\n }|${rights.reversed().joinToString(\" \") { it.value.toString() }}\"\n }\n\n override fun hashCode(): Int {\n var result = items.size\n result = 31 * result + lefts.size\n result = 31 * result + rights.size\n return result\n }\n }\n\n\n fun main() {\n val N = readInt()\n val A = readLongs()\n\n val items = A.mapIndexed { index, it -> Infant(pos = index, value = it) }\n .sortedByDescending { it.value }\n //log(items.joinToString(\"\\n\"))\n\n val table = LazyMap { problem ->\n problem.getOneChoice() ?: problem.let {\n val infant = it.items.first()\n // generate subProblem\n val left = Problem(\n items = it.items.drop(1),\n lefts = it.lefts + infant,\n rights = it.rights\n )\n val right = Problem(\n items = it.items.drop(1),\n lefts = it.lefts,\n rights = it.rights + infant\n )\n\n // generate choices\n val leftValue = get(left) + infant.value * abs(infant.pos - it.minPos)\n val rightValue = get(right) + infant.value * abs(it.maxPos - infant.pos)\n\n // evaluate choices\n val value = if (leftValue < rightValue) rightValue else leftValue\n //log(\"$it = $value\")\n value\n }\n }\n val ans = table[Problem(items = items, lefts = emptySet(), rights = emptySet())]\n println(ans)\n }\n\n\n /*####################################################################################*/\n data class Infant(val pos: Int, val value: Long)\n\n fun readInt() = readLine()!!.toInt()\n fun readLongs() = readLine()!!.split(\" \").map { it.toLong() }\n\n class LazyMap(private val init: LazyMap.(K) -> V) : Map {\n private val memo = HashMap()\n override fun get(key: K): V {\n return memo[key] ?: init(key).memorizingAt(key)\n }\n\n\n private fun V.memorizingAt(key: K): V {\n memo[key] = this\n return this\n }\n\n override val entries: Set>\n get() = memo.entries\n override val keys: Set\n get() = memo.keys\n override val size: Int\n get() = memo.size\n override val values: Collection\n get() = memo.values\n\n override fun containsKey(key: K): Boolean = memo.containsKey(key)\n override fun containsValue(value: V): Boolean = memo.containsValue(value)\n override fun isEmpty(): Boolean = memo.isEmpty()\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "sample_input": "4\n1 3 4 2\n"}, "reference_outputs": ["20\n"], "source_document_id": "p02709", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3469, "cpu_time_ms": 2212, "memory_kb": 270740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s095827181", "group_id": "codeNet:p02712", "input_text": "fun main(args:Array) {\n val input = readLine()!!.toLong()\n var sum = 0L\n for (i in 1..input) {\n if (i%3 == 0L || i%5 == 0L) {\n sum += i\n }\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1586744314, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Kotlin/s095827181.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s095827181", "user_id": "u833404731"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "fun main(args:Array) {\n val input = readLine()!!.toLong()\n var sum = 0L\n for (i in 1..input) {\n if (i%3 == 0L || i%5 == 0L) {\n sum += i\n }\n }\n println(sum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 89, "memory_kb": 34476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s327167868", "group_id": "codeNet:p02712", "input_text": "fun main(args: Array) {\n val n = readLine()!!.split(\" \").map { it.toInt() }[0]\n var count:Long = 0\n for (i in 0..n){\n var iDouble = i.toDouble()\n val threeDouble = 3.toDouble()\n val fiveDouble = 5.toDouble()\n val threeAmari = iDouble % threeDouble\n val fiveAmari = iDouble % fiveDouble\n if (threeAmari != 0.toDouble()){\n if (fiveAmari != 0.toDouble()){\n count += i\n }\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1586740530, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Kotlin/s327167868.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s327167868", "user_id": "u385678999"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.split(\" \").map { it.toInt() }[0]\n var count:Long = 0\n for (i in 0..n){\n var iDouble = i.toDouble()\n val threeDouble = 3.toDouble()\n val fiveDouble = 5.toDouble()\n val threeAmari = iDouble % threeDouble\n val fiveAmari = iDouble % fiveDouble\n if (threeAmari != 0.toDouble()){\n if (fiveAmari != 0.toDouble()){\n count += i\n }\n }\n }\n println(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 192, "memory_kb": 36504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s929310551", "group_id": "codeNet:p02712", "input_text": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val fizzbuzz = (1L..n).filter { it % 3 != 0L && it % 5 != 0L}.sum()\n println(fizzbuzz)\n\n}\n\n\n\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextInt() = sc.nextInt()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Int): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextIntAry(n: Int): IntArray {\n val ary = intAry(n)\n for (i in 0 until n) ary[i] = nextInt()\n return ary\n}\nfun nextLongAry(n: Int): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Int): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\nfun list() = mutableListOf()\nfun intList() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun intSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addIntFunc = {a: Int, b: Int -> a + b}\nval addLongFunc = {a: Long, b: Long -> a + b}\nval mulIntFunc = {a: Int, b: Int -> a * b}\nval mulLongFunc = {a: Long, b: Long -> a * b}\nval maxIntFunc = {a: Int, b: Int -> max(a, b)}\nval maxLongFunc = {a: Long, b: Long -> max(a, b)}\nval minIntFunc = {a: Int, b: Int -> min(a, b)}\nval minLongFunc = {a: Long, b: Long -> min(a, b)}\nval gcdIntFunc = {a: Int, b: Int -> gcd(a, b)}\nval gcdLongFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmIntFunc = {a: Int, b: Int -> lcm(a, b)}\nval lcmLongFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorIntFunc = {a: Int, b: Int -> a xor b}\nval xorLongFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Int, b: Int, op: (Int, Int) -> Int) = op(a, b)\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun Int.a() = this.toLong()\nfun Long.a() = this.toInt()\nfun IntArray.lowerBound(n: Int): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.lowerBound(n: Long): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.intLowerBound(n: Int): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun IntArray.cumsum(op: (Int, Int) -> Int): IntArray {\n val s = intAry(this.size + 1)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Int) {\n repeat(n) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.intCounting(n: Int) {\n repeat(n) {\n val a = nextInt()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Int) {\n repeat(n) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!\nfun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!\nfun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!\nfun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!\ntailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else if (a % b == 0) b else gcd(b, (a % b))\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Int, b: Int): Int = a / gcd(a, b) * b\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Int) {\n private val fac = LongArray(max)\n private val finv = LongArray(max)\n private val inv = LongArray(max)\n private val p = MOD.a()\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Int, r: Int): Long = if (n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Int, private var searched: Int = 0, private var nextIndex: Int = 0) {\n private val size = fact(n)\n private val permList = Array(size) { IntArray(n) { 0 } }\n\n private tailrec fun fact(n: Int, ans: Int = 1): Int {\n return if (n == 0) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, IntArray(n) { 0 }, Array(n) { false })\n }\n\n private fun create(num: Int, list: IntArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): IntArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Int, var past: Int = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Int, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Int): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size, -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Int): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size, LINF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass UnionFind(size: Int) {\n private val par = IntArray(size) { it }\n private val size = IntArray(size) { 1 }\n fun root(x: Int): Int {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Int, y: Int): Boolean = root(x) == root(y)\n fun unite(x: Int, y: Int) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Int): Int = size[root(x)]\n}\n\nclass IntSegmentTree(\n private val a: IntArray,\n private val op: (Int, Int) -> Int,\n private val def: Int = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = intAry(2 * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Int, value: Int) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Int, b: Int) = getSub(a, b, 0, 0, n)\n fun getSub(a: Int, b: Int, k: Int, l: Int, r: Int): Int {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\nclass LongSegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2 * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Int, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Int, b: Int) = getSub(a, b, 0, 0, n)\n fun getSub(a: Int, b: Int, k: Int, l: Int, r: Int): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n}", "language": "Kotlin", "metadata": {"date": 1586739811, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Kotlin/s929310551.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929310551", "user_id": "u581625805"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val fizzbuzz = (1L..n).filter { it % 3 != 0L && it % 5 != 0L}.sum()\n println(fizzbuzz)\n\n}\n\n\n\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextInt() = sc.nextInt()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Int): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextIntAry(n: Int): IntArray {\n val ary = intAry(n)\n for (i in 0 until n) ary[i] = nextInt()\n return ary\n}\nfun nextLongAry(n: Int): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Int): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\nfun list() = mutableListOf()\nfun intList() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun intSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addIntFunc = {a: Int, b: Int -> a + b}\nval addLongFunc = {a: Long, b: Long -> a + b}\nval mulIntFunc = {a: Int, b: Int -> a * b}\nval mulLongFunc = {a: Long, b: Long -> a * b}\nval maxIntFunc = {a: Int, b: Int -> max(a, b)}\nval maxLongFunc = {a: Long, b: Long -> max(a, b)}\nval minIntFunc = {a: Int, b: Int -> min(a, b)}\nval minLongFunc = {a: Long, b: Long -> min(a, b)}\nval gcdIntFunc = {a: Int, b: Int -> gcd(a, b)}\nval gcdLongFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmIntFunc = {a: Int, b: Int -> lcm(a, b)}\nval lcmLongFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorIntFunc = {a: Int, b: Int -> a xor b}\nval xorLongFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Int, b: Int, op: (Int, Int) -> Int) = op(a, b)\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun Int.a() = this.toLong()\nfun Long.a() = this.toInt()\nfun IntArray.lowerBound(n: Int): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.lowerBound(n: Long): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.intLowerBound(n: Int): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Int {\n var ok = this.size\n var ng = -1\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun IntArray.cumsum(op: (Int, Int) -> Int): IntArray {\n val s = intAry(this.size + 1)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Int) {\n repeat(n) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.intCounting(n: Int) {\n repeat(n) {\n val a = nextInt()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Int) {\n repeat(n) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!\nfun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!\nfun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!\nfun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!\ntailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else if (a % b == 0) b else gcd(b, (a % b))\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Int, b: Int): Int = a / gcd(a, b) * b\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Int) {\n private val fac = LongArray(max)\n private val finv = LongArray(max)\n private val inv = LongArray(max)\n private val p = MOD.a()\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Int, r: Int): Long = if (n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Int, private var searched: Int = 0, private var nextIndex: Int = 0) {\n private val size = fact(n)\n private val permList = Array(size) { IntArray(n) { 0 } }\n\n private tailrec fun fact(n: Int, ans: Int = 1): Int {\n return if (n == 0) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, IntArray(n) { 0 }, Array(n) { false })\n }\n\n private fun create(num: Int, list: IntArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): IntArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Int, var past: Int = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Int, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Int): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size, -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Int): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size, LINF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass UnionFind(size: Int) {\n private val par = IntArray(size) { it }\n private val size = IntArray(size) { 1 }\n fun root(x: Int): Int {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Int, y: Int): Boolean = root(x) == root(y)\n fun unite(x: Int, y: Int) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Int): Int = size[root(x)]\n}\n\nclass IntSegmentTree(\n private val a: IntArray,\n private val op: (Int, Int) -> Int,\n private val def: Int = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = intAry(2 * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Int, value: Int) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Int, b: Int) = getSub(a, b, 0, 0, n)\n fun getSub(a: Int, b: Int, k: Int, l: Int, r: Int): Int {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\nclass LongSegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2 * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Int, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Int, b: Int) = getSub(a, b, 0, 0, n)\n fun getSub(a: Int, b: Int, k: Int, l: Int, r: Int): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 15125, "cpu_time_ms": 181, "memory_kb": 59028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s346727660", "group_id": "codeNet:p02715", "input_text": "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 Comb(n: Int, val mod: Int) {\n\n val F = LongArray(n + 1)\n val I = LongArray(n + 1)\n init {\n F[0] = 1\n for (i in 1..n) {\n F[i] = F[i - 1] * i % mod\n }\n I[n] = powMod(F[n], (mod - 2).toLong(), mod)\n for (i in n - 1 downTo 0) {\n I[i] = I[i + 1] * (i + 1) % mod\n }\n }\n\n private fun powMod(a: Long, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod(a * a % mod, n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n }\n\n fun comb(n: Int, k: Int): Long {\n return F[n] * I[k] % mod * I[n - k] % mod\n }\n\n fun inv(x: Int): Long {\n return I[x] * F[x - 1] % mod\n }\n\n /**\n * nのグループからk回重複ありで選ぶ組み合わせ数\n * n - 1のしきりとkの○で考える\n */\n fun H(n: Int, k: Int) = comb(n + k - 1, k)\n}\nfun powMod(a: Int, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod((a.toLong() * a % mod).toInt(), n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n}\n\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = nl()\n val K = ni()\n var ans = 0L\n val dp = LongArray(K + 10)\n for (g in 1 .. K) {\n val m = K / g\n val v= (MOD + g - dp[g]) % MOD\n val cmb = powMod(m, N, MOD)\n ans = (ans + cmb * v % MOD) % MOD\n var x = g\n while(x <= K) {\n dp[x] = (dp[x] + v) % MOD\n x += g\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 // なんか本番でエラーでる\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * 勝手にimport消されるのを防ぎたい\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}", "language": "Kotlin", "metadata": {"date": 1586761779, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02715.html", "problem_id": "p02715", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02715/input.txt", "sample_output_relpath": "derived/input_output/data/p02715/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02715/Kotlin/s346727660.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346727660", "user_id": "u460609472"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "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 Comb(n: Int, val mod: Int) {\n\n val F = LongArray(n + 1)\n val I = LongArray(n + 1)\n init {\n F[0] = 1\n for (i in 1..n) {\n F[i] = F[i - 1] * i % mod\n }\n I[n] = powMod(F[n], (mod - 2).toLong(), mod)\n for (i in n - 1 downTo 0) {\n I[i] = I[i + 1] * (i + 1) % mod\n }\n }\n\n private fun powMod(a: Long, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod(a * a % mod, n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n }\n\n fun comb(n: Int, k: Int): Long {\n return F[n] * I[k] % mod * I[n - k] % mod\n }\n\n fun inv(x: Int): Long {\n return I[x] * F[x - 1] % mod\n }\n\n /**\n * nのグループからk回重複ありで選ぶ組み合わせ数\n * n - 1のしきりとkの○で考える\n */\n fun H(n: Int, k: Int) = comb(n + k - 1, k)\n}\nfun powMod(a: Int, n: Long, mod: Int): Long {\n if (n == 0L) return 1\n val res = powMod((a.toLong() * a % mod).toInt(), n / 2, mod)\n return if (n % 2 == 1L) res * a % mod else res\n}\n\n\nclass Solver(stream: InputStream, private val out: java.io.PrintWriter) {\n fun solve() {\n val N = nl()\n val K = ni()\n var ans = 0L\n val dp = LongArray(K + 10)\n for (g in 1 .. K) {\n val m = K / g\n val v= (MOD + g - dp[g]) % MOD\n val cmb = powMod(m, N, MOD)\n ans = (ans + cmb * v % MOD) % MOD\n var x = g\n while(x <= K) {\n dp[x] = (dp[x] + v) % MOD\n x += g\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 // なんか本番でエラーでる\n System.getenv(\"MY_DEBUG\") != null\n } catch (t: Throwable) {\n false\n }\n\n private var tokenizer: StringTokenizer? = null\n private val reader = BufferedReader(InputStreamReader(stream), 32768)\n private fun next(): String {\n while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n private fun ni() = next().toInt()\n private fun nl() = next().toLong()\n private fun ns() = next()\n private fun na(n: Int, offset: Int = 0): IntArray {\n return map(n) { ni() + offset }\n }\n private fun nal(n: Int, offset: Int = 0): LongArray {\n val res = LongArray(n)\n for (i in 0 until n) {\n res[i] = nl() + offset\n }\n return res\n }\n\n private fun na2(n: Int, offset: Int = 0): Array {\n val a = Array(2){IntArray(n)}\n for (i in 0 until n) {\n for (e in a) {\n e[i] = ni() + offset\n }\n }\n return a\n }\n\n private inline fun map(n: Int, f: (Int) -> Int): IntArray {\n val res = IntArray(n)\n for (i in 0 until n) {\n res[i] = f(i)\n }\n return res\n }\n\n private inline fun debug(msg: () -> String) {\n if (isDebug) System.err.println(msg())\n }\n\n private fun debug(a: LongArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: IntArray) {\n debug { a.joinToString(\" \") }\n }\n\n private fun debug(a: BooleanArray) {\n debug { a.map { if (it) 1 else 0 }.joinToString(\"\") }\n }\n\n private fun debugDim(A: Array) {\n if (isDebug) {\n for (a in A) {\n debug(a)\n }\n }\n }\n\n /**\n * 勝手にimport消されるのを防ぎたい\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}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be enormous, print the value modulo (10^9+7).\n\nHere \\gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the sum of \\gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)\n=1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\nSample Input 2\n\n3 200\n\nSample Output 2\n\n10813692\n\nSample Input 3\n\n100000 100000\n\nSample Output 3\n\n742202979\n\nBe sure to print the sum modulo (10^9+7).", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02715", "source_text": "Score : 500 points\n\nProblem Statement\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be enormous, print the value modulo (10^9+7).\n\nHere \\gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the sum of \\gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)\n=1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\nSample Input 2\n\n3 200\n\nSample Output 2\n\n10813692\n\nSample Input 3\n\n100000 100000\n\nSample Output 3\n\n742202979\n\nBe sure to print the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3603, "cpu_time_ms": 131, "memory_kb": 35380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s988826730", "group_id": "codeNet:p02715", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval k = scn.nextInt()\n\n\tval arr = Array(k+1){ ModInt.ZERO}\n\tvar ans = ModInt(0)\n\tfor (i in k downTo 1){\n\t\tval t = k/i\n\t\tvar cnt = ModInt.pow(t, n)\n\t\tfor (p in 2..t){\n\t\t\tcnt -= arr[p*i]\n\t\t}\n\t\tarr[i] = cnt\n\t\tans += cnt*i\n\t}\n\tprintln(ans)\n}\n\nclass ModInt {\n\tvar v: Long\n\t\tprivate set\n\tconstructor(v: Int){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v.toLong() % MOD\n\t\t\tv==Int.MIN_VALUE -> 852516373\n\t\t\telse -> MOD.toLong() - (-v%MOD)\n\t\t}\n\t}\n\tconstructor(v: Long){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v % MOD\n\t\t\tv==Long.MIN_VALUE -> 708828003\n\t\t\telse -> MOD - (-v%MOD)\n\t\t}\n\t}\n\n\toverride fun toString() = v.toString()\n\tfun toInt() = v.toInt()\n\tfun toLong() = v\n\toverride fun equals(other: Any?): Boolean {\n\t\treturn if (other is ModInt) v == other.v else false\n\t}\n\toverride fun hashCode() = 31*17 + v.hashCode()\n\n\toperator fun unaryPlus() = this\n\toperator fun unaryMinus() = ModInt(MOD-this.v)\n\n\tprivate operator fun plus(o: Long) = ModInt(this.v + o)\n\toperator fun plus(o: ModInt) = this.plus(o.v)\n\toperator fun plus(o: Int) = this.plus(o.toLong())\n\tprivate operator fun minus(o: Long) = this.plus(-o)\n\toperator fun minus(o: ModInt) = this.minus(o.v)\n\toperator fun minus(o: Int) = this.minus(o.toLong())\n\tprivate operator fun times(o: Long) = ModInt(this.v*o)\n\toperator fun times(o: ModInt) = this.times(o.v)\n\toperator fun times(o: Int) = this.times(o.toLong())\n\tprivate operator fun div(o: Long) = this.times(pow(o, MOD-2))\n\toperator fun div(o: ModInt) = this.div(o.v)\n\toperator fun div(o: Int) = this.div(o.toLong())\n\n\toperator fun inc() = this.plus(1)\n\toperator fun dec() = this.minus(1)\n\n\tcompanion object{\n\t\tconst val MOD = 1000000007\n\t\tval ZERO = ModInt(0)\n\n\t\tprivate fun pow(b:Long, e: Int): ModInt{\n\t\t\tif (b==1L) return ModInt(1)\n\t\t\tvar ans = 1L\n\t\t\tvar b = b; var e = e\n\t\t\twhile (e!=0){\n\t\t\t\tif (e%2==1) ans = (ans*b)%MOD\n\t\t\t\tb = (b*b)%MOD\n\t\t\t\te /= 2\n\t\t\t}\n\t\t\treturn ModInt(ans)\n\t\t}\n\t\tfun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)\n\t\tfun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)\n\t}\n}", "language": "Kotlin", "metadata": {"date": 1586742658, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02715.html", "problem_id": "p02715", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02715/input.txt", "sample_output_relpath": "derived/input_output/data/p02715/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02715/Kotlin/s988826730.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s988826730", "user_id": "u914590612"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval k = scn.nextInt()\n\n\tval arr = Array(k+1){ ModInt.ZERO}\n\tvar ans = ModInt(0)\n\tfor (i in k downTo 1){\n\t\tval t = k/i\n\t\tvar cnt = ModInt.pow(t, n)\n\t\tfor (p in 2..t){\n\t\t\tcnt -= arr[p*i]\n\t\t}\n\t\tarr[i] = cnt\n\t\tans += cnt*i\n\t}\n\tprintln(ans)\n}\n\nclass ModInt {\n\tvar v: Long\n\t\tprivate set\n\tconstructor(v: Int){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v.toLong() % MOD\n\t\t\tv==Int.MIN_VALUE -> 852516373\n\t\t\telse -> MOD.toLong() - (-v%MOD)\n\t\t}\n\t}\n\tconstructor(v: Long){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v % MOD\n\t\t\tv==Long.MIN_VALUE -> 708828003\n\t\t\telse -> MOD - (-v%MOD)\n\t\t}\n\t}\n\n\toverride fun toString() = v.toString()\n\tfun toInt() = v.toInt()\n\tfun toLong() = v\n\toverride fun equals(other: Any?): Boolean {\n\t\treturn if (other is ModInt) v == other.v else false\n\t}\n\toverride fun hashCode() = 31*17 + v.hashCode()\n\n\toperator fun unaryPlus() = this\n\toperator fun unaryMinus() = ModInt(MOD-this.v)\n\n\tprivate operator fun plus(o: Long) = ModInt(this.v + o)\n\toperator fun plus(o: ModInt) = this.plus(o.v)\n\toperator fun plus(o: Int) = this.plus(o.toLong())\n\tprivate operator fun minus(o: Long) = this.plus(-o)\n\toperator fun minus(o: ModInt) = this.minus(o.v)\n\toperator fun minus(o: Int) = this.minus(o.toLong())\n\tprivate operator fun times(o: Long) = ModInt(this.v*o)\n\toperator fun times(o: ModInt) = this.times(o.v)\n\toperator fun times(o: Int) = this.times(o.toLong())\n\tprivate operator fun div(o: Long) = this.times(pow(o, MOD-2))\n\toperator fun div(o: ModInt) = this.div(o.v)\n\toperator fun div(o: Int) = this.div(o.toLong())\n\n\toperator fun inc() = this.plus(1)\n\toperator fun dec() = this.minus(1)\n\n\tcompanion object{\n\t\tconst val MOD = 1000000007\n\t\tval ZERO = ModInt(0)\n\n\t\tprivate fun pow(b:Long, e: Int): ModInt{\n\t\t\tif (b==1L) return ModInt(1)\n\t\t\tvar ans = 1L\n\t\t\tvar b = b; var e = e\n\t\t\twhile (e!=0){\n\t\t\t\tif (e%2==1) ans = (ans*b)%MOD\n\t\t\t\tb = (b*b)%MOD\n\t\t\t\te /= 2\n\t\t\t}\n\t\t\treturn ModInt(ans)\n\t\t}\n\t\tfun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)\n\t\tfun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)\n\t}\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be enormous, print the value modulo (10^9+7).\n\nHere \\gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the sum of \\gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)\n=1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\nSample Input 2\n\n3 200\n\nSample Output 2\n\n10813692\n\nSample Input 3\n\n100000 100000\n\nSample Output 3\n\n742202979\n\nBe sure to print the sum modulo (10^9+7).", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02715", "source_text": "Score : 500 points\n\nProblem Statement\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be enormous, print the value modulo (10^9+7).\n\nHere \\gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the sum of \\gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)\n=1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\nSample Input 2\n\n3 200\n\nSample Output 2\n\n10813692\n\nSample Input 3\n\n100000 100000\n\nSample Output 3\n\n742202979\n\nBe sure to print the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2087, "cpu_time_ms": 199, "memory_kb": 58420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s505600306", "group_id": "codeNet:p02716", "input_text": "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 a = Array(n) { sc.nextLong() }.toMutableList()\n val m = (n + 1) / 2\n val left = Array(m + 1) { 0L }\n val right = Array(m + 1) { 0L }\n for (i in 0 until m) {\n left[i + 1] = left[i] + a[2 * i]\n }\n for (i in m - 1 downTo 0) {\n right[i] = right[i + 1] + if (n % 2 == 1 && i == m - 1) a[n - 1] else a[2 * i + 1]\n }\n if (n % 2 == 0) {\n var max = Long.MIN_VALUE\n for (i in 0..m) {\n val v = left[i] + right[i]\n max = Math.max(max, v)\n }\n println(max)\n } else {\n a.add(a.last())\n val maxL = Array(m + 1) { 0L }\n val maxR = Array(m + 1) { 0L }\n for (i in 0 until m) {\n maxL[i + 1] = Math.max(maxL[i] + a[2 * i + 1], left[i + 1])\n }\n for (i in m - 1 downTo 0) {\n maxR[i] = maxR[i + 1] + a[2 * i]\n }\n var max = Long.MIN_VALUE\n for (i in 0 until m) {\n val v = maxL[i] + maxR[i + 1]\n max = Math.max(max, v)\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", "language": "Kotlin", "metadata": {"date": 1586812738, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02716.html", "problem_id": "p02716", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02716/input.txt", "sample_output_relpath": "derived/input_output/data/p02716/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02716/Kotlin/s505600306.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s505600306", "user_id": "u190507186"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "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 a = Array(n) { sc.nextLong() }.toMutableList()\n val m = (n + 1) / 2\n val left = Array(m + 1) { 0L }\n val right = Array(m + 1) { 0L }\n for (i in 0 until m) {\n left[i + 1] = left[i] + a[2 * i]\n }\n for (i in m - 1 downTo 0) {\n right[i] = right[i + 1] + if (n % 2 == 1 && i == m - 1) a[n - 1] else a[2 * i + 1]\n }\n if (n % 2 == 0) {\n var max = Long.MIN_VALUE\n for (i in 0..m) {\n val v = left[i] + right[i]\n max = Math.max(max, v)\n }\n println(max)\n } else {\n a.add(a.last())\n val maxL = Array(m + 1) { 0L }\n val maxR = Array(m + 1) { 0L }\n for (i in 0 until m) {\n maxL[i + 1] = Math.max(maxL[i] + a[2 * i + 1], left[i + 1])\n }\n for (i in m - 1 downTo 0) {\n maxR[i] = maxR[i + 1] + a[2 * i]\n }\n var max = Long.MIN_VALUE\n for (i in 0 until m) {\n val v = maxL[i] + maxR[i + 1]\n max = Math.max(max, v)\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", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence A_1, ..., A_N of length N.\n\nWe will choose exactly \\left\\lfloor \\frac{N}{2} \\right\\rfloor elements from this sequence so that no two adjacent elements are chosen.\n\nFind the maximum possible sum of the chosen elements.\n\nHere \\lfloor x \\rfloor denotes the greatest integer not greater than x.\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n|A_i|\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the maximum possible sum of the chosen elements.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n12\n\nChoosing 2, 4, and 6 makes the sum 12, which is the maximum possible value.\n\nSample Input 2\n\n5\n-1000 -100 -10 0 10\n\nSample Output 2\n\n0\n\nChoosing -10 and 10 makes the sum 0, which is the maximum possible value.\n\nSample Input 3\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nWatch out for overflow.\n\nSample Input 4\n\n27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\n\nSample Output 4\n\n295", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02716", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence A_1, ..., A_N of length N.\n\nWe will choose exactly \\left\\lfloor \\frac{N}{2} \\right\\rfloor elements from this sequence so that no two adjacent elements are chosen.\n\nFind the maximum possible sum of the chosen elements.\n\nHere \\lfloor x \\rfloor denotes the greatest integer not greater than x.\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n|A_i|\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the maximum possible sum of the chosen elements.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n12\n\nChoosing 2, 4, and 6 makes the sum 12, which is the maximum possible value.\n\nSample Input 2\n\n5\n-1000 -100 -10 0 10\n\nSample Output 2\n\n0\n\nChoosing -10 and 10 makes the sum 0, which is the maximum possible value.\n\nSample Input 3\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nWatch out for overflow.\n\nSample Input 4\n\n27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\n\nSample Output 4\n\n295", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1868, "cpu_time_ms": 354, "memory_kb": 69548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s870194985", "group_id": "codeNet:p02719", "input_text": "fun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map{it.toInt()}\n println(Math.min(n%k, Math.abs(k-n%k)))\n}\n", "language": "Kotlin", "metadata": {"date": 1588135176, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s870194985.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s870194985", "user_id": "u906501980"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map{it.toInt()}\n println(Math.min(n%k, Math.abs(k-n%k)))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 135, "cpu_time_ms": 237, "memory_kb": 37916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s012764186", "group_id": "codeNet:p02719", "input_text": "fun main(args: Array) {\n val x = readLine()!!.split(\" \").map { it.toLong() }\n val n = x[0]\n val k = x[1]\n val kaisuuA = n / k\n val hikumonoA = k * kaisuuA\n val kaisuuB = kaisuuA + 1\n val hikumonoB = k * kaisuuB\n val a = Math.abs(n - hikumonoA)\n val b = Math.abs(n - hikumonoB)\n if (a > b){\n println(b)\n } else {\n println(a)\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1586053617, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s012764186.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s012764186", "user_id": "u385678999"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.split(\" \").map { it.toLong() }\n val n = x[0]\n val k = x[1]\n val kaisuuA = n / k\n val hikumonoA = k * kaisuuA\n val kaisuuB = kaisuuA + 1\n val hikumonoB = k * kaisuuB\n val a = Math.abs(n - hikumonoA)\n val b = Math.abs(n - hikumonoB)\n if (a > b){\n println(b)\n } else {\n println(a)\n }\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 388, "cpu_time_ms": 273, "memory_kb": 37996}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s542836263", "group_id": "codeNet:p02719", "input_text": "fun main(args: Array) = abc161c()\n\nfun abc161c() {\n val (n, k) = readLine()!!.split(' ').map { it.toLong() }\n\n if (n < k) return println(n)\n if (n % k == 0L) return println(0)\n\n val rem = n % k\n\n println(listOf(rem, Math.abs(k - rem)).min()!!)\n}\n", "language": "Kotlin", "metadata": {"date": 1586052658, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s542836263.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s542836263", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) = abc161c()\n\nfun abc161c() {\n val (n, k) = readLine()!!.split(' ').map { it.toLong() }\n\n if (n < k) return println(n)\n if (n % k == 0L) return println(0)\n\n val rem = n % k\n\n println(listOf(rem, Math.abs(k - rem)).min()!!)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 233, "memory_kb": 37948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192912133", "group_id": "codeNet:p02719", "input_text": "fun main(args : Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n\n if (n <= k) {\n println(Math.min(n, Math.abs(k-n)))\n } else {\n println(if (n % k == 0L) 0 else Math.min(n, 1))\n }\n}", "language": "Kotlin", "metadata": {"date": 1586049702, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/Kotlin/s192912133.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s192912133", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toLong() }\n\n if (n <= k) {\n println(Math.min(n, Math.abs(k-n)))\n } else {\n println(if (n % k == 0L) 0 else Math.min(n, 1))\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 233, "cpu_time_ms": 250, "memory_kb": 36028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s572964758", "group_id": "codeNet:p02720", "input_text": "import kotlin.math.*\nimport java.util.*\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = ArrayDeque()\n (1..9).forEach { q += it.toString() }\n var x = \"\"\n repeat(k) {\n x = q.remove()\n val y = x.last()\n if (y != '0') q += x + (y - 1)\n q += x + y\n if (y != '9') q += x + (y + 1)\n }\n println(x)\n}\n", "language": "Kotlin", "metadata": {"date": 1590205257, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02720.html", "problem_id": "p02720", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02720/input.txt", "sample_output_relpath": "derived/input_output/data/p02720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02720/Kotlin/s572964758.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572964758", "user_id": "u051841332"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import kotlin.math.*\nimport java.util.*\n\nfun main(args: Array) {\n val k = readLine()!!.toInt()\n val q = ArrayDeque()\n (1..9).forEach { q += it.toString() }\n var x = \"\"\n repeat(k) {\n x = q.remove()\n val y = x.last()\n if (y != '0') q += x + (y - 1)\n q += x + y\n if (y != '9') q += x + (y + 1)\n }\n println(x)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "sample_input": "15\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02720", "source_text": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 346, "cpu_time_ms": 198, "memory_kb": 64952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s099794123", "group_id": "codeNet:p02720", "input_text": "fun pow(base: Int, exp: Int): Long{\n var ans=1L\n if(exp==0) return ans\n if (exp%2==1) ans*=base\n return ans*pow(base*base, exp/2)\n}\n\nfun main(args: Array) {\n var k= readLine()!!.toInt()\n var a=Array(9){(it+1).toLong()}.toMutableList()\n var value: Long\n var last: Long\n for(i in 0 until k-1){\n value=a[i]\n last=value%10\n if (last==0L){\n a.add(10*value+last)\n a.add(10*value+last+1)\n }else if(last==9L){\n a.add(10*value+last-1)\n a.add(10*value+last)\n }else{\n a.add(10*value+last-1)\n a.add(10*value+last)\n a.add(10*value+last+1)\n }\n }\n println(a[k-1])\n}", "language": "Kotlin", "metadata": {"date": 1586104646, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02720.html", "problem_id": "p02720", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02720/input.txt", "sample_output_relpath": "derived/input_output/data/p02720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02720/Kotlin/s099794123.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s099794123", "user_id": "u456173040"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "fun pow(base: Int, exp: Int): Long{\n var ans=1L\n if(exp==0) return ans\n if (exp%2==1) ans*=base\n return ans*pow(base*base, exp/2)\n}\n\nfun main(args: Array) {\n var k= readLine()!!.toInt()\n var a=Array(9){(it+1).toLong()}.toMutableList()\n var value: Long\n var last: Long\n for(i in 0 until k-1){\n value=a[i]\n last=value%10\n if (last==0L){\n a.add(10*value+last)\n a.add(10*value+last+1)\n }else if(last==9L){\n a.add(10*value+last-1)\n a.add(10*value+last)\n }else{\n a.add(10*value+last-1)\n a.add(10*value+last)\n a.add(10*value+last+1)\n }\n }\n println(a[k-1])\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "sample_input": "15\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02720", "source_text": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 710, "cpu_time_ms": 272, "memory_kb": 41144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s257274116", "group_id": "codeNet:p02723", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n println(if (s[2] == s[3] && s[4] == s[5]) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1591791669, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02723.html", "problem_id": "p02723", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02723/input.txt", "sample_output_relpath": "derived/input_output/data/p02723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02723/Kotlin/s257274116.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s257274116", "user_id": "u172820018"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n println(if (s[2] == s[3] && s[4] == s[5]) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "sample_input": "sippuu\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02723", "source_text": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 121, "cpu_time_ms": 204, "memory_kb": 31736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s979760127", "group_id": "codeNet:p02724", "input_text": "fun main(args: Array) {\n val line = readLine()!!.trim()\n val amount: Long = line.toLong()\n\n val count500 = amount / 500L\n val amari500 = amount % 500L\n val count5 = amari500 % 5L\n\n val uresisa = count500 * 1000 + count5 * 5\n\n println(uresisa)\n}", "language": "Kotlin", "metadata": {"date": 1585444504, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Kotlin/s979760127.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s979760127", "user_id": "u146343951"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "fun main(args: Array) {\n val line = readLine()!!.trim()\n val amount: Long = line.toLong()\n\n val count500 = amount / 500L\n val amari500 = amount % 500L\n val count5 = amari500 % 5L\n\n val uresisa = count500 * 1000 + count5 * 5\n\n println(uresisa)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 273, "cpu_time_ms": 243, "memory_kb": 33784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s565115350", "group_id": "codeNet:p02724", "input_text": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n println((x / 500 * 1000) + (x % 500 / 5 * 5))\n}\n", "language": "Kotlin", "metadata": {"date": 1585443802, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Kotlin/s565115350.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565115350", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n println((x / 500 * 1000) + (x % 500 / 5 * 5))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 232, "memory_kb": 29788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s857494675", "group_id": "codeNet:p02724", "input_text": "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 var x = sc.nextLong()\n var ans = 0L\n ans += x / 500 * 1000\n x %= 500\n ans += x / 5 * 5\n println(ans)\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", "language": "Kotlin", "metadata": {"date": 1585443748, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Kotlin/s857494675.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s857494675", "user_id": "u190507186"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "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 var x = sc.nextLong()\n var ans = 0L\n ans += x / 500 * 1000\n x %= 500\n ans += x / 5 * 5\n println(ans)\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", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 927, "cpu_time_ms": 242, "memory_kb": 29468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s796290218", "group_id": "codeNet:p02725", "input_text": "fun main(args: Array) {\n var (k, n) = readLine()!!.split(\" \").map{ it.toInt() }\n var a = readLine()!!.split(\" \").map{ it.toInt() }\n var diff_max = k - a[n-1] + a[0]\n var old = a[0]\n for (ai in a.slice(1..n-1)) {\n diff_max = Math.max(diff_max, ai - old)\n }\n println(k-diff_max)\n}\n", "language": "Kotlin", "metadata": {"date": 1588098642, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02725/input.txt", "sample_output_relpath": "derived/input_output/data/p02725/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02725/Kotlin/s796290218.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s796290218", "user_id": "u906501980"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n var (k, n) = readLine()!!.split(\" \").map{ it.toInt() }\n var a = readLine()!!.split(\" \").map{ it.toInt() }\n var diff_max = k - a[n-1] + a[0]\n var old = a[0]\n for (ai in a.slice(1..n-1)) {\n diff_max = Math.max(diff_max, ai - old)\n }\n println(k-diff_max)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 662, "memory_kb": 82608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s904477831", "group_id": "codeNet:p02725", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scan = Scanner(System.`in`)\n var ar = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var k=ar[0]\n var n=ar[1]\n\n var a = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var min = Int.MAX_VALUE\n var temp = 0\n\n for(i in 0..a.size-1)\n {\n if(i+1<=a.size-1)\n temp= a[i]+k-a[i+1]\n if(temp) {\n val scan = Scanner(System.`in`)\n var ar = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var k=ar[0]\n var n=ar[1]\n\n var a = scan.nextLine().split(\" \").map{ it.trim().toInt() }.toTypedArray()\n var min = Int.MAX_VALUE\n var temp = 0\n\n for(i in 0..a.size-1)\n {\n if(i+1<=a.size-1)\n temp= a[i]+k-a[i+1]\n if(temp) {\n val sc = Scanner(System.`in`)\n\n val (k, n) = sc.nextLine().split(\" \").map { it.toInt() }\n val a = sc.nextLine().split(\" \").map { it.toInt() }\n\n val sub = (1 until n).map { a[it] - a[it-1] }.toList() as MutableList\n\n sub.add(k-a[n-1]+a[0])\n\n val m = sub.max()\n\n println(sub.sum()-m!!)\n}\n", "language": "Kotlin", "metadata": {"date": 1585444885, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02725/input.txt", "sample_output_relpath": "derived/input_output/data/p02725/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02725/Kotlin/s848504780.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848504780", "user_id": "u079781329"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val (k, n) = sc.nextLine().split(\" \").map { it.toInt() }\n val a = sc.nextLine().split(\" \").map { it.toInt() }\n\n val sub = (1 until n).map { a[it] - a[it-1] }.toList() as MutableList\n\n sub.add(k-a[n-1]+a[0])\n\n val m = sub.max()\n\n println(sub.sum()-m!!)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 365, "cpu_time_ms": 771, "memory_kb": 84096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s071964111", "group_id": "codeNet:p02726", "input_text": "fun main(args: Array) {\n fun minDistance(i: Int, j: Int, x: Int, y: Int): Int {\n return Math.min(j - i, Math.min(Math.abs(x - i) + 1 + Math.abs(j - y), Math.abs(y - i) + 1 + Math.abs(j - x)))\n }\n val (n, x, y) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n\n val distances = hashMapOf()\n 0.until(n - 1).forEach { i ->\n (i + 1).until(n).forEach { j ->\n val distance = minDistance(i + 1, j + 1, x, y)\n distances[distance] = distances[distance]?.let { it + 1 } ?: 1\n }\n }\n 1.until(n).forEach { i ->\n println(distances[i] ?: 0)\n }\n}", "language": "Kotlin", "metadata": {"date": 1585509199, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02726/input.txt", "sample_output_relpath": "derived/input_output/data/p02726/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02726/Kotlin/s071964111.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071964111", "user_id": "u979429407"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "fun main(args: Array) {\n fun minDistance(i: Int, j: Int, x: Int, y: Int): Int {\n return Math.min(j - i, Math.min(Math.abs(x - i) + 1 + Math.abs(j - y), Math.abs(y - i) + 1 + Math.abs(j - x)))\n }\n val (n, x, y) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n\n val distances = hashMapOf()\n 0.until(n - 1).forEach { i ->\n (i + 1).until(n).forEach { j ->\n val distance = minDistance(i + 1, j + 1, x, y)\n distances[distance] = distances[distance]?.let { it + 1 } ?: 1\n }\n }\n 1.until(n).forEach { i ->\n println(distances[i] ?: 0)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 628, "cpu_time_ms": 477, "memory_kb": 66964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s451639307", "group_id": "codeNet:p02726", "input_text": "\nimport java.util.*\n\nfun main(args: Array) = ABC160D.main()\n\nobject ABC160D {\n fun log(message: Any?) {\n //println(message)// TODO: ←消す\n }\n\n val graph: WeightedGraph\n val nodes: List\n val N: Int\n\n init {\n val (n, x, y) = readInts()\n N = n\n nodes = (1..n).map { NumNode(it) }\n val edges1 = (\n (1..n - 1).map { nodes[it - 1] to nodes[it] } + listOf(nodes[x - 1] to nodes[y - 1])\n ).associate { it to 1 }\n val edges = edges1 + edges1.mapKeys { it.key.second to it.key.first }\n log(edges.keys.joinToString(\"\\n\"))\n graph = WeightedGraph(edges)\n }\n\n fun main() {\n val combination = Combination().generate(nodes, 2)\n\n val distBucket = (1..N - 1).map { 0 }.toMutableList() // k->個数\n\n val dists = combination.map {\n val i = it.first()\n val j = it.last()\n val d = dist(i, j)\n if (distBucket[d-1] != null) distBucket[d-1] = distBucket[d-1] + 1\n d\n }.toList()\n\n println(distBucket.joinToString(\"\\n\"))\n\n }\n\n fun dist(i: NumNode, j: NumNode): Int { // i,j: 1-origin\n val search = DijkstraSearch(\n start = i,\n goal = j,\n graph = graph\n )\n val d = search.searchPathAndCost()!!.second\n log(\"$i->$j: $d\")\n return d\n }\n\n data class NumNode(val n: Int) : Node {\n override fun neighbors(): Sequence = graph.neighbors[this]!!.asSequence()\n\n override fun toString(): String = n.toString()\n }\n\n /*####################################################################################*/\n\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\n class Combination : BasicCombinator() {\n override fun List.chooseRemains(i: Int): List = this.drop(i + 1)\n }\n\n abstract class BasicCombinator {\n abstract fun List.chooseRemains(i: Int): List\n\n fun generate(items: List, k: Int): Sequence> {\n when {\n (k < 0) ->\n throw IllegalArgumentException()\n (k == 0) ->\n return emptySequence()\n (k == 1) ->\n return items.asSequence().map { listOf(it) }\n else ->\n return items.asSequence().mapIndexed { index, first ->\n val remains = items.chooseRemains(index)\n generate(remains, k - 1).map { first + it }\n }.flatten()\n }\n }\n\n private operator fun T.plus(other: List): List {\n val list = mutableListOf(this)\n list.addAll(other)\n return list\n }\n }\n\n interface Node {\n fun neighbors(): Sequence\n }\n\n class WeightedGraph(\n weightedEdges: Map, Int>\n ) {\n val nodes: Set = weightedEdges.keys.flatMap { it.toList() }.distinct().toSet()\n val weights: Map, Int> = weightedEdges\n val neighbors: Map> =\n weights.keys.groupBy { it.first }.mapValues { e -> e.value.map { it.second }.toSet() }\n\n fun neighborsOf(node: T): Sequence {\n return neighbors[node]?.asSequence() ?: emptySequence()\n }\n }\n\n class DijkstraSearch(\n val start: T,\n val goal: T,\n val graph: WeightedGraph\n ) {\n fun searchPathAndCost(): Pair, Int>? {\n val weight = graph.weights\n\n var goalState: Pair, Int>? = null\n val costMemo: MutableMap = HashMap(graph.neighbors.size)\n costMemo[start] = 0\n val search = BreadthFirstSearch(\n root = start,\n initialState = (emptyList() to 0),\n shouldVisit = { from, to, state ->\n val prevCost = costMemo[to] ?: Int.MAX_VALUE\n val newCost = weight[from to to]?.plus(state.second) ?: Int.MAX_VALUE\n val shouldVisit = (from != goal) && (newCost < prevCost)\n if (shouldVisit) costMemo[to] = newCost\n shouldVisit\n },\n whenVisit = { from, to, state ->\n val newState = state.first + to to costMemo[to]!!\n if (to == goal) goalState = newState\n newState\n })\n search.traverse()\n return goalState\n }\n }\n\n class BreadthFirstSearch(\n root: T,\n initialState: S,\n whenVisit: (from: T?, to: T, state: S) -> S = { f, t, s -> s },\n shouldVisit: (from: T, to: T, state: S) -> Boolean\n ) : SearchBase(root, initialState, whenVisit, shouldVisit) {\n private val stack = LinkedList>()\n override fun queue(p: Pair) {\n stack.addLast(p)\n }\n\n override fun pop(): Pair? {\n val first = stack.firstOrNull()\n if (first != null) stack.removeFirst()\n return first\n }\n }\n\n interface Search {\n fun traverseSequence(): Sequence\n fun traverse(): Unit = traverseSequence().forEach { }\n }\n\n abstract class SearchBase(\n private val root: T,\n private val initialState: S,\n private val whenVisit: (from: T?, to: T, state: S) -> S = { f, t, s -> s },\n private val shouldVisit: (from: T, to: T, state: S) -> Boolean\n ) : Search {\n abstract fun queue(p: Pair)\n abstract fun pop(): Pair?\n\n override fun traverseSequence(): Sequence {\n val state = whenVisit(null, root, initialState)\n queue(root to state)\n return searchAll()\n }\n\n private fun searchAll(): Sequence = generateSequence {\n pop()?.let { p ->\n val first = p.first\n val state = p.second\n first.neighbors().filter {\n shouldVisit(first, it as T, state)\n }.forEach {\n val newState = whenVisit(first, it as T, state)\n queue(it to newState)\n }\n first\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1585449093, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02726/input.txt", "sample_output_relpath": "derived/input_output/data/p02726/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02726/Kotlin/s451639307.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s451639307", "user_id": "u981616728"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "\nimport java.util.*\n\nfun main(args: Array) = ABC160D.main()\n\nobject ABC160D {\n fun log(message: Any?) {\n //println(message)// TODO: ←消す\n }\n\n val graph: WeightedGraph\n val nodes: List\n val N: Int\n\n init {\n val (n, x, y) = readInts()\n N = n\n nodes = (1..n).map { NumNode(it) }\n val edges1 = (\n (1..n - 1).map { nodes[it - 1] to nodes[it] } + listOf(nodes[x - 1] to nodes[y - 1])\n ).associate { it to 1 }\n val edges = edges1 + edges1.mapKeys { it.key.second to it.key.first }\n log(edges.keys.joinToString(\"\\n\"))\n graph = WeightedGraph(edges)\n }\n\n fun main() {\n val combination = Combination().generate(nodes, 2)\n\n val distBucket = (1..N - 1).map { 0 }.toMutableList() // k->個数\n\n val dists = combination.map {\n val i = it.first()\n val j = it.last()\n val d = dist(i, j)\n if (distBucket[d-1] != null) distBucket[d-1] = distBucket[d-1] + 1\n d\n }.toList()\n\n println(distBucket.joinToString(\"\\n\"))\n\n }\n\n fun dist(i: NumNode, j: NumNode): Int { // i,j: 1-origin\n val search = DijkstraSearch(\n start = i,\n goal = j,\n graph = graph\n )\n val d = search.searchPathAndCost()!!.second\n log(\"$i->$j: $d\")\n return d\n }\n\n data class NumNode(val n: Int) : Node {\n override fun neighbors(): Sequence = graph.neighbors[this]!!.asSequence()\n\n override fun toString(): String = n.toString()\n }\n\n /*####################################################################################*/\n\n fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\n class Combination : BasicCombinator() {\n override fun List.chooseRemains(i: Int): List = this.drop(i + 1)\n }\n\n abstract class BasicCombinator {\n abstract fun List.chooseRemains(i: Int): List\n\n fun generate(items: List, k: Int): Sequence> {\n when {\n (k < 0) ->\n throw IllegalArgumentException()\n (k == 0) ->\n return emptySequence()\n (k == 1) ->\n return items.asSequence().map { listOf(it) }\n else ->\n return items.asSequence().mapIndexed { index, first ->\n val remains = items.chooseRemains(index)\n generate(remains, k - 1).map { first + it }\n }.flatten()\n }\n }\n\n private operator fun T.plus(other: List): List {\n val list = mutableListOf(this)\n list.addAll(other)\n return list\n }\n }\n\n interface Node {\n fun neighbors(): Sequence\n }\n\n class WeightedGraph(\n weightedEdges: Map, Int>\n ) {\n val nodes: Set = weightedEdges.keys.flatMap { it.toList() }.distinct().toSet()\n val weights: Map, Int> = weightedEdges\n val neighbors: Map> =\n weights.keys.groupBy { it.first }.mapValues { e -> e.value.map { it.second }.toSet() }\n\n fun neighborsOf(node: T): Sequence {\n return neighbors[node]?.asSequence() ?: emptySequence()\n }\n }\n\n class DijkstraSearch(\n val start: T,\n val goal: T,\n val graph: WeightedGraph\n ) {\n fun searchPathAndCost(): Pair, Int>? {\n val weight = graph.weights\n\n var goalState: Pair, Int>? = null\n val costMemo: MutableMap = HashMap(graph.neighbors.size)\n costMemo[start] = 0\n val search = BreadthFirstSearch(\n root = start,\n initialState = (emptyList() to 0),\n shouldVisit = { from, to, state ->\n val prevCost = costMemo[to] ?: Int.MAX_VALUE\n val newCost = weight[from to to]?.plus(state.second) ?: Int.MAX_VALUE\n val shouldVisit = (from != goal) && (newCost < prevCost)\n if (shouldVisit) costMemo[to] = newCost\n shouldVisit\n },\n whenVisit = { from, to, state ->\n val newState = state.first + to to costMemo[to]!!\n if (to == goal) goalState = newState\n newState\n })\n search.traverse()\n return goalState\n }\n }\n\n class BreadthFirstSearch(\n root: T,\n initialState: S,\n whenVisit: (from: T?, to: T, state: S) -> S = { f, t, s -> s },\n shouldVisit: (from: T, to: T, state: S) -> Boolean\n ) : SearchBase(root, initialState, whenVisit, shouldVisit) {\n private val stack = LinkedList>()\n override fun queue(p: Pair) {\n stack.addLast(p)\n }\n\n override fun pop(): Pair? {\n val first = stack.firstOrNull()\n if (first != null) stack.removeFirst()\n return first\n }\n }\n\n interface Search {\n fun traverseSequence(): Sequence\n fun traverse(): Unit = traverseSequence().forEach { }\n }\n\n abstract class SearchBase(\n private val root: T,\n private val initialState: S,\n private val whenVisit: (from: T?, to: T, state: S) -> S = { f, t, s -> s },\n private val shouldVisit: (from: T, to: T, state: S) -> Boolean\n ) : Search {\n abstract fun queue(p: Pair)\n abstract fun pop(): Pair?\n\n override fun traverseSequence(): Sequence {\n val state = whenVisit(null, root, initialState)\n queue(root to state)\n return searchAll()\n }\n\n private fun searchAll(): Sequence = generateSequence {\n pop()?.let { p ->\n val first = p.first\n val state = p.second\n first.neighbors().filter {\n shouldVisit(first, it as T, state)\n }.forEach {\n val newState = whenVisit(first, it as T, state)\n queue(it to newState)\n }\n first\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6375, "cpu_time_ms": 2112, "memory_kb": 123156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s490051105", "group_id": "codeNet:p02726", "input_text": "fun main(args: Array) {\n val (N, X, Y) = readLine()!!.split(\" \").map(String::toInt)\n\n // グラフ作成\n val G = Array(N) { mutableListOf() }\n for (i in 0 until N) {\n if (i != N - 1) {\n G[i].add(i + 1)\n }\n if (i != 0) {\n G[i].add(i - 1)\n }\n }\n G[X - 1].add(Y - 1)\n G[Y - 1].add(X - 1)\n\n\n // 探索処理\n var keiro = mutableListOf()\n fun dfs(d: Int, v: Int): Set {\n if (d == 1) {\n return G[v].filterNot { keiro.contains(it) }.toSet()\n }\n\n val set = mutableSetOf()\n for (_v in G[v]) {\n keiro.add(_v)\n set.addAll(dfs(d - 1, _v))\n }\n return set\n\n }\n\n for (i in 1 until N) {\n var ans = mutableSetOf>()\n for (v in 0 until N) {\n // 通った経路\n keiro = mutableListOf(v)\n val tmp = dfs(i, v)\n // 通った経路は距離iではないので除外する\n // i to j i < j にして重複を取り除く\n ans.addAll(tmp.filterNot { keiro.contains(it) }\n .map {\n if (v < it) {\n v to it\n } else {\n it to v\n }\n }\n )\n }\n println(ans.size)\n }\n}\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1585449032, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02726/input.txt", "sample_output_relpath": "derived/input_output/data/p02726/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02726/Kotlin/s490051105.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s490051105", "user_id": "u085288971"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, X, Y) = readLine()!!.split(\" \").map(String::toInt)\n\n // グラフ作成\n val G = Array(N) { mutableListOf() }\n for (i in 0 until N) {\n if (i != N - 1) {\n G[i].add(i + 1)\n }\n if (i != 0) {\n G[i].add(i - 1)\n }\n }\n G[X - 1].add(Y - 1)\n G[Y - 1].add(X - 1)\n\n\n // 探索処理\n var keiro = mutableListOf()\n fun dfs(d: Int, v: Int): Set {\n if (d == 1) {\n return G[v].filterNot { keiro.contains(it) }.toSet()\n }\n\n val set = mutableSetOf()\n for (_v in G[v]) {\n keiro.add(_v)\n set.addAll(dfs(d - 1, _v))\n }\n return set\n\n }\n\n for (i in 1 until N) {\n var ans = mutableSetOf>()\n for (v in 0 until N) {\n // 通った経路\n keiro = mutableListOf(v)\n val tmp = dfs(i, v)\n // 通った経路は距離iではないので除外する\n // i to j i < j にして重複を取り除く\n ans.addAll(tmp.filterNot { keiro.contains(it) }\n .map {\n if (v < it) {\n v to it\n } else {\n it to v\n }\n }\n )\n }\n println(ans.size)\n }\n}\n\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1382, "cpu_time_ms": 2111, "memory_kb": 141380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s094624938", "group_id": "codeNet:p02728", "input_text": "import java.util.*\n\nfun main(args:Array) {\n\n val mod = 1000000007L\n val n = readLine()!!.toInt()\n val dp = LongArray(n)\n val factorial = LongArray(n+1)\n val edges = Array(n){HashSet()}\n val s = Array(n){0}\n val visited = BooleanArray(n)\n\n factorial[0] = 1\n factorial[1] = 1\n\n for(i in 2 ..n) {\n factorial[i] = (factorial[i-1] * i) % mod\n }\n\n for(i in 0 until n - 1) {\n var (a,b) = readLine()!!.split(\" \").map { it.toInt() }\n a--\n b--\n edges[a].add(b)\n edges[b].add(a)\n }\n\n fun dfs(cur:Int): Int {\n var cnt = 0\n visited[cur] = true\n for(adj in edges[cur]) {\n if(visited[adj]) continue\n cnt += dfs(adj)\n }\n visited[cur] = false\n s[cur] = cnt + 1\n dp[cur] = (factorial[s[cur] - 1])\n var k = 0\n for(adj in edges[cur]) {\n if(visited[adj]) {\n ++k\n continue\n }\n dp[cur] = (dp[cur] * dp[adj] / factorial[s[adj]]) % mod\n dp[cur] %= mod\n }\n while (k > 1) {\n \n }\n //dp[i] = (s[cur] - 1)! * dp[\n return s[cur]\n }\n\n fun dfs2(root:Int) {\n visited[root] = true\n for(child in edges[root]) {\n if(visited[child]) continue\n //dp[child] = dp[cur] * s[child] / factorial[ n - s[child] ]\n// dp[child] = dp[root] * s[child] / factorial [ n - s[child]]\n val v = (n - s[child]).toLong()\n dp[child] = (dp[root] * s[child]) % mod\n\n\n\n if(dp[child] / v == 0L) {\n dp[child] = (dp[child] + mod) / v\n if(dp[child]==0L) {\n while (true){\n\n }\n }\n } else {\n dp[child] = dp[child] / v\n }\n\n// dp[child] = dp[root] * s[child] / (n - s[child])\n dp[child] %= mod\n dfs2(child)\n }\n visited[root] = false\n }\n dfs(0)\n dfs2(0)\n\n for(i in 0 until n) {\n println(dp[i])\n }\n\n //dp[i] = (size_tree_root(i) - 1)! * pi [\n // inv[i] = 1 / (factorial(s[i] - 1))\n // dp[i] = inv[i] * dp[i-1] * factorial(s[i]) / [ n - s[i]]!\n}", "language": "Kotlin", "metadata": {"date": 1585685504, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02728.html", "problem_id": "p02728", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02728/input.txt", "sample_output_relpath": "derived/input_output/data/p02728/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02728/Kotlin/s094624938.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s094624938", "user_id": "u682597394"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array) {\n\n val mod = 1000000007L\n val n = readLine()!!.toInt()\n val dp = LongArray(n)\n val factorial = LongArray(n+1)\n val edges = Array(n){HashSet()}\n val s = Array(n){0}\n val visited = BooleanArray(n)\n\n factorial[0] = 1\n factorial[1] = 1\n\n for(i in 2 ..n) {\n factorial[i] = (factorial[i-1] * i) % mod\n }\n\n for(i in 0 until n - 1) {\n var (a,b) = readLine()!!.split(\" \").map { it.toInt() }\n a--\n b--\n edges[a].add(b)\n edges[b].add(a)\n }\n\n fun dfs(cur:Int): Int {\n var cnt = 0\n visited[cur] = true\n for(adj in edges[cur]) {\n if(visited[adj]) continue\n cnt += dfs(adj)\n }\n visited[cur] = false\n s[cur] = cnt + 1\n dp[cur] = (factorial[s[cur] - 1])\n var k = 0\n for(adj in edges[cur]) {\n if(visited[adj]) {\n ++k\n continue\n }\n dp[cur] = (dp[cur] * dp[adj] / factorial[s[adj]]) % mod\n dp[cur] %= mod\n }\n while (k > 1) {\n \n }\n //dp[i] = (s[cur] - 1)! * dp[\n return s[cur]\n }\n\n fun dfs2(root:Int) {\n visited[root] = true\n for(child in edges[root]) {\n if(visited[child]) continue\n //dp[child] = dp[cur] * s[child] / factorial[ n - s[child] ]\n// dp[child] = dp[root] * s[child] / factorial [ n - s[child]]\n val v = (n - s[child]).toLong()\n dp[child] = (dp[root] * s[child]) % mod\n\n\n\n if(dp[child] / v == 0L) {\n dp[child] = (dp[child] + mod) / v\n if(dp[child]==0L) {\n while (true){\n\n }\n }\n } else {\n dp[child] = dp[child] / v\n }\n\n// dp[child] = dp[root] * s[child] / (n - s[child])\n dp[child] %= mod\n dfs2(child)\n }\n visited[root] = false\n }\n dfs(0)\n dfs2(0)\n\n for(i in 0 until n) {\n println(dp[i])\n }\n\n //dp[i] = (size_tree_root(i) - 1)! * pi [\n // inv[i] = 1 / (factorial(s[i] - 1))\n // dp[i] = inv[i] * dp[i-1] * factorial(s[i]) / [ n - s[i]]!\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nFor each k=1, ..., N, solve the problem below:\n\nConsider writing a number on each vertex in the tree in the following manner:\n\nFirst, write 1 on Vertex k.\n\nThen, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:\n\nChoose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.\n\nFind the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nFor each k=1, 2, ..., N in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n3\n1 2\n1 3\n\nSample Output 1\n\n2\n1\n1\n\nThe graph in this input is as follows:\n\nFor k=1, there are two ways in which we can write the numbers on the vertices, as follows:\n\nWriting 1, 2, 3 on Vertex 1, 2, 3, respectively\n\nWriting 1, 3, 2 on Vertex 1, 2, 3, respectively\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n1\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 3\n\n2\n8\n12\n3\n3\n\nThe graph in this input is as follows:\n\nSample Input 4\n\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n\nSample Output 4\n\n40\n280\n840\n120\n120\n504\n72\n72\n\nThe graph in this input is as follows:", "sample_input": "3\n1 2\n1 3\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02728", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nFor each k=1, ..., N, solve the problem below:\n\nConsider writing a number on each vertex in the tree in the following manner:\n\nFirst, write 1 on Vertex k.\n\nThen, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:\n\nChoose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.\n\nFind the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nFor each k=1, 2, ..., N in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n3\n1 2\n1 3\n\nSample Output 1\n\n2\n1\n1\n\nThe graph in this input is as follows:\n\nFor k=1, there are two ways in which we can write the numbers on the vertices, as follows:\n\nWriting 1, 2, 3 on Vertex 1, 2, 3, respectively\n\nWriting 1, 3, 2 on Vertex 1, 2, 3, respectively\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n1\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 3\n\n2\n8\n12\n3\n3\n\nThe graph in this input is as follows:\n\nSample Input 4\n\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n\nSample Output 4\n\n40\n280\n840\n120\n120\n504\n72\n72\n\nThe graph in this input is as follows:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2256, "cpu_time_ms": 2521, "memory_kb": 168096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s504730645", "group_id": "codeNet:p02730", "input_text": "fun main(args: Array){\n val s = readLine()!!\n val front = s.substring(0, (s.length-1)/2)\n val end = s.substring((s.length+3)/2 - 1, s.length)\n val check1 = palindromeCheck(s)\n val check2 = palindromeCheck(front)\n val check3 = palindromeCheck(end)\n if(check1 && check2 && check3){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}\n\nfun palindromeCheck(s: String): Boolean{\n val length = s.length\n val lastIndex = s.lastIndex\n if(length % 2 != 0) {\n for (i in 0..(length - 1) / 2) {\n if (s[i] != s[lastIndex - i]) {\n return false\n }\n }\n }else{\n for (i in 0..length / 2) {\n if (s[i] != s[lastIndex - i]) {\n return false\n }\n }\n }\n return true\n}", "language": "Kotlin", "metadata": {"date": 1587253828, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s504730645.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504730645", "user_id": "u376497013"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array){\n val s = readLine()!!\n val front = s.substring(0, (s.length-1)/2)\n val end = s.substring((s.length+3)/2 - 1, s.length)\n val check1 = palindromeCheck(s)\n val check2 = palindromeCheck(front)\n val check3 = palindromeCheck(end)\n if(check1 && check2 && check3){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}\n\nfun palindromeCheck(s: String): Boolean{\n val length = s.length\n val lastIndex = s.lastIndex\n if(length % 2 != 0) {\n for (i in 0..(length - 1) / 2) {\n if (s[i] != s[lastIndex - i]) {\n return false\n }\n }\n }else{\n for (i in 0..length / 2) {\n if (s[i] != s[lastIndex - i]) {\n return false\n }\n }\n }\n return true\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 803, "cpu_time_ms": 208, "memory_kb": 33660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s331393069", "group_id": "codeNet:p02730", "input_text": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val s = readLine()!!.reversed()\n if (s != s.reversed()) {\n println(\"No\")\n return\n }\n\n val pre = s.substring(0, (s.length - 1) / 2)\n if (pre != pre.reversed()) {\n println(\"No\")\n return\n }\n\n val suf = s.substring((s.length + 3) / 2 - 1)\n if (suf != suf.reversed()) {\n println(\"No\")\n return\n }\n println(\"Yes\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1585350608, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s331393069.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331393069", "user_id": "u784448849"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val s = readLine()!!.reversed()\n if (s != s.reversed()) {\n println(\"No\")\n return\n }\n\n val pre = s.substring(0, (s.length - 1) / 2)\n if (pre != pre.reversed()) {\n println(\"No\")\n return\n }\n\n val suf = s.substring((s.length + 3) / 2 - 1)\n if (suf != suf.reversed()) {\n println(\"No\")\n return\n }\n println(\"Yes\")\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 869, "cpu_time_ms": 204, "memory_kb": 33776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s584347168", "group_id": "codeNet:p02730", "input_text": "fun String.zenhan() = substring(0 until (length / 2))\nfun String.kouhan() = substring((length + 2) / 2)\nfun String.isKaibun() = zenhan() == kouhan().reversed()\nfun String.isKaibun2() = zenhan().isKaibun()\nfun String.isKaibun3() = kouhan().isKaibun()\n\nfun main(args: Array) {\n val input = readLine()!!\n if (input.isKaibun() && input.isKaibun2() && input.isKaibun3()) {\n \"Yes\"\n } else {\n \"No\"\n }.let { println(it) }\n}\n", "language": "Kotlin", "metadata": {"date": 1584928250, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s584347168.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s584347168", "user_id": "u784615990"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun String.zenhan() = substring(0 until (length / 2))\nfun String.kouhan() = substring((length + 2) / 2)\nfun String.isKaibun() = zenhan() == kouhan().reversed()\nfun String.isKaibun2() = zenhan().isKaibun()\nfun String.isKaibun3() = kouhan().isKaibun()\n\nfun main(args: Array) {\n val input = readLine()!!\n if (input.isKaibun() && input.isKaibun2() && input.isKaibun3()) {\n \"Yes\"\n } else {\n \"No\"\n }.let { println(it) }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 450, "cpu_time_ms": 215, "memory_kb": 33728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s702711227", "group_id": "codeNet:p02730", "input_text": "import java.util.Scanner\n\nfun main(args: Array){\n val scn = Scanner(System.`in`)\n val str = scn.nextLine()\n val reverse = str!!.reversed()\n val n = str.length\n\n if(n % 2 == 0 || n !in 3..99){\n print(\"No\")\n return\n }\n\n val regex = Regex(\"[a-z]*\")\n if(!regex.matches(str)){\n print(\"No\")\n return\n }\n\n\n\n if(str!=reverse){\n print(\"No\")\n return\n }\n\n val mae = str.substring(0..(((n-1)/2)-1))\n val reverseMae = mae.reversed()\n\n if(mae!=reverseMae){\n print(\"No\")\n return\n }\n\n val ushiro = str.substring((((n+3)/2)-1)..(n-1))\n val reverseUshiro = ushiro.reversed()\n\n if(ushiro!=reverseUshiro){\n print(\"No\")\n return\n }\n\n\n print(\"Yes\")\n}", "language": "Kotlin", "metadata": {"date": 1584926959, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s702711227.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s702711227", "user_id": "u455957433"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array){\n val scn = Scanner(System.`in`)\n val str = scn.nextLine()\n val reverse = str!!.reversed()\n val n = str.length\n\n if(n % 2 == 0 || n !in 3..99){\n print(\"No\")\n return\n }\n\n val regex = Regex(\"[a-z]*\")\n if(!regex.matches(str)){\n print(\"No\")\n return\n }\n\n\n\n if(str!=reverse){\n print(\"No\")\n return\n }\n\n val mae = str.substring(0..(((n-1)/2)-1))\n val reverseMae = mae.reversed()\n\n if(mae!=reverseMae){\n print(\"No\")\n return\n }\n\n val ushiro = str.substring((((n+3)/2)-1)..(n-1))\n val reverseUshiro = ushiro.reversed()\n\n if(ushiro!=reverseUshiro){\n print(\"No\")\n return\n }\n\n\n print(\"Yes\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 764, "cpu_time_ms": 234, "memory_kb": 29692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s956489519", "group_id": "codeNet:p02730", "input_text": "fun main(args: Array) {\n val S = readString()\n val N = S.length\n\n fun f(s: String): Boolean {\n return s == s.reversed()\n }\n\n if (f(S) && f(S.substring(0, (N - 1) / 2)) && f(S.substring((N + 2) / 2))) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLong() = readString().toLong()\nfun readLongs() = readStrings().map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1584925721, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Kotlin/s956489519.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s956489519", "user_id": "u979004569"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readString()\n val N = S.length\n\n fun f(s: String): Boolean {\n return s == s.reversed()\n }\n\n if (f(S) && f(S.substring(0, (N - 1) / 2)) && f(S.substring((N + 2) / 2))) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLong() = readString().toLong()\nfun readLongs() = readStrings().map { it.toLong() }\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 528, "cpu_time_ms": 209, "memory_kb": 33768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s316087184", "group_id": "codeNet:p02732", "input_text": "\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n readInt()\n val a = readLongList()\n\n val counter = a.groupingBy { it }.eachCount().toMap()\n\n var ans = 0L\n counter.filter { it.value > 1 }.forEach {\n ans += it.value * (it.value - 1) / 2\n }\n\n a.forEach {\n println(ans - (counter[it]!! - 1))\n }\n}", "language": "Kotlin", "metadata": {"date": 1593331388, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02732/input.txt", "sample_output_relpath": "derived/input_output/data/p02732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02732/Kotlin/s316087184.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s316087184", "user_id": "u657541767"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\nfun Array>.print() {\n this.forEach {\n println(it.joinToString(\" \"))\n }\n}\n\nfun main() {\n readInt()\n val a = readLongList()\n\n val counter = a.groupingBy { it }.eachCount().toMap()\n\n var ans = 0L\n counter.filter { it.value > 1 }.forEach {\n ans += it.value * (it.value - 1) / 2\n }\n\n a.forEach {\n println(ans - (counter[it]!! - 1))\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "sample_input": "5\n1 1 2 1 2\n"}, "reference_outputs": ["2\n2\n3\n2\n3\n"], "source_document_id": "p02732", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 632, "cpu_time_ms": 1417, "memory_kb": 90344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s299307361", "group_id": "codeNet:p02732", "input_text": "import java.io.File\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map(String::toInt) // list of ints\nprivate fun readLongs() = readStrings().map(String::toLong) // list of longs\n\nvar n: Int = 0\n\nfun main(args: Array) {\n val n = readInt()\n val a = readInts()\n\n val num = IntArray(n) {0}\n (0 until n).forEach {\n num[a[it] - 1]++\n }\n val t:Long = num.filter { it > 1 }.map { it * (it - 1L) / 2L }.sum()\n\n println(a.map {\n val x = num[it - 1]\n if (x > 1) {\n t - (x * (x - 1) / 2) + ((x - 1) * (x - 2) / 2)\n } else {\n t\n }\n }.joinToString(\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1584927193, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02732/input.txt", "sample_output_relpath": "derived/input_output/data/p02732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02732/Kotlin/s299307361.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s299307361", "user_id": "u059223549"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "import java.io.File\n\nprivate fun readLn() = readLine()!! // string line\nprivate fun readInt() = readLn().toInt() // single int\nprivate fun readLong() = readLn().toLong() // single long\nprivate fun readStrings() = readLn().split(\" \") // list of strings\nprivate fun readInts() = readStrings().map(String::toInt) // list of ints\nprivate fun readLongs() = readStrings().map(String::toLong) // list of longs\n\nvar n: Int = 0\n\nfun main(args: Array) {\n val n = readInt()\n val a = readInts()\n\n val num = IntArray(n) {0}\n (0 until n).forEach {\n num[a[it] - 1]++\n }\n val t:Long = num.filter { it > 1 }.map { it * (it - 1L) / 2L }.sum()\n\n println(a.map {\n val x = num[it - 1]\n if (x > 1) {\n t - (x * (x - 1) / 2) + ((x - 1) * (x - 2) / 2)\n } else {\n t\n }\n }.joinToString(\"\\n\"))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "sample_input": "5\n1 1 2 1 2\n"}, "reference_outputs": ["2\n2\n3\n2\n3\n"], "source_document_id": "p02732", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 857, "cpu_time_ms": 832, "memory_kb": 100592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s243997839", "group_id": "codeNet:p02733", "input_text": "fun main() {\n val h = nextInt()\n val w = nextInt()\n val k = nextInt()\n val s = Array(h) {\n next().toCharArray()\n }\n var min = h + w\n for (i in 0 until (Math.pow(2.0, (h - 1).toDouble()).toInt())) {\n val cutList = mutableListOf()\n var current = Cut()\n cutList += current\n current.lines += s[0]\n var mod = 1\n for (j in 1 until h) {\n if (i and mod != 0) {\n current = Cut()\n cutList += current\n }\n current.lines += s[j]\n mod *= 2\n }\n var count = Integer.bitCount(i)\n var ok = true\n var needCut = false\n loop@ for (j in 0 until w) {\n for (cut in cutList) {\n if (cut.add(j) > k) {\n ok = false\n break@loop\n }\n if (cut.sum > k) {\n needCut = true\n }\n }\n if (needCut) {\n count++\n for (cut in cutList) {\n cut.sum = 0\n }\n needCut = false\n }\n }\n if (ok) {\n min = Math.min(min, count)\n }\n }\n println(min)\n}\n\nclass Cut {\n val lines = mutableListOf()\n var sum = 0\n\n fun add(i: Int): Int {\n var res = 0\n for (line in lines) {\n res += line[i] - '0'\n }\n sum += res\n return res\n }\n}\n\nval scanner = java.util.Scanner(System.`in`)\nfun next(): String = scanner.next()\nfun nextInt() = scanner.nextInt()\nfun nextLong() = scanner.nextLong()\nfun nextLine(): String = scanner.nextLine()\nfun nextList() = nextLine().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextIntArray(n: Int) = IntArray(n) { nextInt() }\nfun nextLongList() = nextList().map(String::toLong)\nfun printYesNo(isYes: Boolean) = println(if (isYes) \"Yes\" else \"No\")\n\nfun main(args: Array) = main()", "language": "Kotlin", "metadata": {"date": 1588455193, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02733.html", "problem_id": "p02733", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02733/input.txt", "sample_output_relpath": "derived/input_output/data/p02733/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02733/Kotlin/s243997839.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s243997839", "user_id": "u896320985"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val h = nextInt()\n val w = nextInt()\n val k = nextInt()\n val s = Array(h) {\n next().toCharArray()\n }\n var min = h + w\n for (i in 0 until (Math.pow(2.0, (h - 1).toDouble()).toInt())) {\n val cutList = mutableListOf()\n var current = Cut()\n cutList += current\n current.lines += s[0]\n var mod = 1\n for (j in 1 until h) {\n if (i and mod != 0) {\n current = Cut()\n cutList += current\n }\n current.lines += s[j]\n mod *= 2\n }\n var count = Integer.bitCount(i)\n var ok = true\n var needCut = false\n loop@ for (j in 0 until w) {\n for (cut in cutList) {\n if (cut.add(j) > k) {\n ok = false\n break@loop\n }\n if (cut.sum > k) {\n needCut = true\n }\n }\n if (needCut) {\n count++\n for (cut in cutList) {\n cut.sum = 0\n }\n needCut = false\n }\n }\n if (ok) {\n min = Math.min(min, count)\n }\n }\n println(min)\n}\n\nclass Cut {\n val lines = mutableListOf()\n var sum = 0\n\n fun add(i: Int): Int {\n var res = 0\n for (line in lines) {\n res += line[i] - '0'\n }\n sum += res\n return res\n }\n}\n\nval scanner = java.util.Scanner(System.`in`)\nfun next(): String = scanner.next()\nfun nextInt() = scanner.nextInt()\nfun nextLong() = scanner.nextLong()\nfun nextLine(): String = scanner.nextLine()\nfun nextList() = nextLine().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextIntArray(n: Int) = IntArray(n) { nextInt() }\nfun nextLongList() = nextList().map(String::toLong)\nfun printYesNo(isYes: Boolean) = println(if (isYes) \"Yes\" else \"No\")\n\nfun main(args: Array) = main()", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\n\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\n\nWe will cut the bar some number of times to divide it into some number of blocks. In each cut, we cut the whole bar by a line running along some boundaries of squares from end to end of the bar.\n\nHow many times do we need to cut the bar so that every block after the cuts has K or less white squares?\n\nConstraints\n\n1 \\leq H \\leq 10\n\n1 \\leq W \\leq 1000\n\n1 \\leq K \\leq H \\times W\n\nS_{i,j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nS_{1,1}S_{1,2}...S_{1,W}\n:\nS_{H,1}S_{H,2}...S_{H,W}\n\nOutput\n\nPrint the number of minimum times the bar needs to be cut so that every block after the cuts has K or less white squares.\n\nSample Input 1\n\n3 5 4\n11100\n10001\n00111\n\nSample Output 1\n\n2\n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and 4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the right.\n\nSample Input 2\n\n3 5 8\n11100\n10001\n00111\n\nSample Output 2\n\n0\n\nNo cut is needed.\n\nSample Input 3\n\n4 10 4\n1110010010\n1000101110\n0011101001\n1101000111\n\nSample Output 3\n\n3", "sample_input": "3 5 4\n11100\n10001\n00111\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02733", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\n\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\n\nWe will cut the bar some number of times to divide it into some number of blocks. In each cut, we cut the whole bar by a line running along some boundaries of squares from end to end of the bar.\n\nHow many times do we need to cut the bar so that every block after the cuts has K or less white squares?\n\nConstraints\n\n1 \\leq H \\leq 10\n\n1 \\leq W \\leq 1000\n\n1 \\leq K \\leq H \\times W\n\nS_{i,j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nS_{1,1}S_{1,2}...S_{1,W}\n:\nS_{H,1}S_{H,2}...S_{H,W}\n\nOutput\n\nPrint the number of minimum times the bar needs to be cut so that every block after the cuts has K or less white squares.\n\nSample Input 1\n\n3 5 4\n11100\n10001\n00111\n\nSample Output 1\n\n2\n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and 4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the right.\n\nSample Input 2\n\n3 5 8\n11100\n10001\n00111\n\nSample Output 2\n\n0\n\nNo cut is needed.\n\nSample Input 3\n\n4 10 4\n1110010010\n1000101110\n0011101001\n1101000111\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1992, "cpu_time_ms": 376, "memory_kb": 66036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s046044751", "group_id": "codeNet:p02735", "input_text": "fun min(a:Int,b:Int) = if(a) {\n val (H,W)=readLine()!!.split(\" \").map { it.toInt() }\n val s = Array(H){readLine()!!}\n val c = Array(H){Array(W){0}}\n\n c[0][0] = 0\n for(w in 1 until W){\n c[0][w] = c[0][w-1]\n if(s[0][w-1]!=s[0][w])c[0][w] += 1\n }\n for(h in 1 until H){\n c[h][0] = c[h-1][0]\n if(s[h][0]!=s[h-1][0])c[h][0] += 1\n\n for(w in 1 until W){\n var a = c[h][w-1]\n if(s[h][w-1]!=s[h][w])a += 1\n var b = c[h-1][w]\n if(s[h-1][w]!=s[h][w])b += 1\n c[h][w] += min(a,b)\n }\n }\n var result=c[H-1][W-1]/2\n if(s[0][0]=='#' || s[H-1][W-1]=='#')result+=1\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1585454375, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02735/input.txt", "sample_output_relpath": "derived/input_output/data/p02735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02735/Kotlin/s046044751.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s046044751", "user_id": "u586526576"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun min(a:Int,b:Int) = if(a) {\n val (H,W)=readLine()!!.split(\" \").map { it.toInt() }\n val s = Array(H){readLine()!!}\n val c = Array(H){Array(W){0}}\n\n c[0][0] = 0\n for(w in 1 until W){\n c[0][w] = c[0][w-1]\n if(s[0][w-1]!=s[0][w])c[0][w] += 1\n }\n for(h in 1 until H){\n c[h][0] = c[h-1][0]\n if(s[h][0]!=s[h-1][0])c[h][0] += 1\n\n for(w in 1 until W){\n var a = c[h][w-1]\n if(s[h][w-1]!=s[h][w])a += 1\n var b = c[h-1][w]\n if(s[h-1][w]!=s[h][w])b += 1\n c[h][w] += min(a,b)\n }\n }\n var result=c[H-1][W-1]/2\n if(s[0][0]=='#' || s[H-1][W-1]=='#')result+=1\n println(result)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "sample_input": "3 3\n.##\n.#.\n##.\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02735", "source_text": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 733, "cpu_time_ms": 266, "memory_kb": 36232}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s897552085", "group_id": "codeNet:p02735", "input_text": "fun main(args: Array) {\n val (H, W) = listOfInt()\n val S = Array(H) { next() }\n val f = Array(H) { IntArray(W) }\n repeat (H) { i ->\n repeat (W) { j ->\n if (i + j == 0) {\n f[0][0] = if (S[0][0] == '#') 1 else 0\n } else {\n f[i][j] = 1000000007\n if (i > 0) f[i][j] = Math.min(f[i][j], f[i - 1][j] + if (S[i - 1][j] == '.' && S[i][j] == '#') 1 else 0 )\n if (j > 0) f[i][j] = Math.min(f[i][j], f[i][j - 1] + if (S[i][j - 1] == '.' && S[i][j] == '#') 1 else 0 )\n }\n }\n }\n println(f[H - 1][W - 1])\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun nextInt(offset: Int = 0) = nextInt() + offset\nfun nextLong() = java.lang.Long.parseLong(next())\nfun nextLong(offset: Long = 0L) = nextLong() + offset\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\nfun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }\nfun listOfDouble() = listOfString().map { it.toDouble() }\n", "language": "Kotlin", "metadata": {"date": 1584848923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02735/input.txt", "sample_output_relpath": "derived/input_output/data/p02735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02735/Kotlin/s897552085.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897552085", "user_id": "u911700901"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W) = listOfInt()\n val S = Array(H) { next() }\n val f = Array(H) { IntArray(W) }\n repeat (H) { i ->\n repeat (W) { j ->\n if (i + j == 0) {\n f[0][0] = if (S[0][0] == '#') 1 else 0\n } else {\n f[i][j] = 1000000007\n if (i > 0) f[i][j] = Math.min(f[i][j], f[i - 1][j] + if (S[i - 1][j] == '.' && S[i][j] == '#') 1 else 0 )\n if (j > 0) f[i][j] = Math.min(f[i][j], f[i][j - 1] + if (S[i][j - 1] == '.' && S[i][j] == '#') 1 else 0 )\n }\n }\n }\n println(f[H - 1][W - 1])\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun nextInt(offset: Int = 0) = nextInt() + offset\nfun nextLong() = java.lang.Long.parseLong(next())\nfun nextLong(offset: Long = 0L) = nextLong() + offset\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\nfun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }\nfun listOfDouble() = listOfString().map { it.toDouble() }\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "sample_input": "3 3\n.##\n.#.\n##.\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02735", "source_text": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1297, "cpu_time_ms": 262, "memory_kb": 37740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s811775994", "group_id": "codeNet:p02736", "input_text": "fun main(args: Array) {\n\treadLn()\n\tval a = readLn().map { it - '1' }\n\tif (a.min() == a.max()) return println(0)\n\tif (!a.contains(1)) return println(solve(a.map { it / 2 }) * 2)\n\tprintln(solve(a.map { it % 2 }))\n}\n\nprivate fun solve(a: List): Int {\n\tvar two = 0\n\tvar ans = 0\n\tval n = a.size - 1\n\tfor (i in a.indices) {\n\t\tif (two == 0) ans = ans xor a[i]\n\t\ttwo += Integer.numberOfTrailingZeros(n - i) - Integer.numberOfTrailingZeros(i + 1)\n\t}\n\treturn ans\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1584841560, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02736.html", "problem_id": "p02736", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02736/input.txt", "sample_output_relpath": "derived/input_output/data/p02736/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02736/Kotlin/s811775994.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s811775994", "user_id": "u932183990"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n\treadLn()\n\tval a = readLn().map { it - '1' }\n\tif (a.min() == a.max()) return println(0)\n\tif (!a.contains(1)) return println(solve(a.map { it / 2 }) * 2)\n\tprintln(solve(a.map { it % 2 }))\n}\n\nprivate fun solve(a: List): Int {\n\tvar two = 0\n\tvar ans = 0\n\tval n = a.size - 1\n\tfor (i in a.indices) {\n\t\tif (two == 0) ans = ans xor a[i]\n\t\ttwo += Integer.numberOfTrailingZeros(n - i) - Integer.numberOfTrailingZeros(i + 1)\n\t}\n\treturn ans\n}\n\nprivate fun readLn() = readLine()!!\nprivate fun readInt() = readLn().toInt()\nprivate fun readStrings() = readLn().split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "sample_input": "4\n1231\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02736", "source_text": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 652, "cpu_time_ms": 479, "memory_kb": 47924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s143160389", "group_id": "codeNet:p02741", "input_text": "fun main(args: Array) {\n val sequence =\n listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)\n\n val k = readLine()!!.toInt()\n\n println(sequence[k - 1])\n}", "language": "Kotlin", "metadata": {"date": 1586026561, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02741.html", "problem_id": "p02741", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02741/input.txt", "sample_output_relpath": "derived/input_output/data/p02741/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02741/Kotlin/s143160389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143160389", "user_id": "u482808328"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val sequence =\n listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)\n\n val k = readLine()!!.toInt()\n\n println(sequence[k - 1])\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "sample_input": "6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02741", "source_text": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 225, "memory_kb": 33740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s986896289", "group_id": "codeNet:p02741", "input_text": "fun main(args: Array) {\n val xs = listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)\n val k = readLine()!!.toInt()\n println(xs[k - 1])\n}\n", "language": "Kotlin", "metadata": {"date": 1584366697, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02741.html", "problem_id": "p02741", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02741/input.txt", "sample_output_relpath": "derived/input_output/data/p02741/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02741/Kotlin/s986896289.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s986896289", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val xs = listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)\n val k = readLine()!!.toInt()\n println(xs[k - 1])\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "sample_input": "6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02741", "source_text": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 209, "cpu_time_ms": 227, "memory_kb": 31940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s332875779", "group_id": "codeNet:p02742", "input_text": "fun main() {\n val (h, w) = readLine()!!.split(\" \").map(String::toLong)\n\n if (h == 1L || w == 1L) {\n println(1)\n return\n }\n println(((w + 1) / 2) * ((h + 1) / 2) + (w / 2) * (h / 2))\n}", "language": "Kotlin", "metadata": {"date": 1589438483, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/Kotlin/s332875779.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s332875779", "user_id": "u085288971"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main() {\n val (h, w) = readLine()!!.split(\" \").map(String::toLong)\n\n if (h == 1L || w == 1L) {\n println(1)\n return\n }\n println(((w + 1) / 2) * ((h + 1) / 2) + (w / 2) * (h / 2))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 209, "cpu_time_ms": 97, "memory_kb": 36288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s549936915", "group_id": "codeNet:p02742", "input_text": "fun main(main: Array) {\n val (h, w) = readLine()!!.split(\" \").map { it.toLong() }\n if(h === 1L || w === 1L) {\n print(1)\n }\n else {\n if(0L === (h * w) % 2) {\n print((h * w) / 2)\n }\n else {\n print((h * w) / 2 + 1)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1588359987, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/Kotlin/s549936915.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s549936915", "user_id": "u124119858"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(main: Array) {\n val (h, w) = readLine()!!.split(\" \").map { it.toLong() }\n if(h === 1L || w === 1L) {\n print(1)\n }\n else {\n if(0L === (h * w) % 2) {\n print((h * w) / 2)\n }\n else {\n print((h * w) / 2 + 1)\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 300, "cpu_time_ms": 243, "memory_kb": 37812}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s630786217", "group_id": "codeNet:p02742", "input_text": "fun main(args: Array) {\n val (h, w) = readLine()!!.split(' ').map { it.toInt() }\n\n if (h == 1 && w == 1) {\n println(1)\n } else {\n println((h * w + 1) / 2)\n }\n}", "language": "Kotlin", "metadata": {"date": 1584828887, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/Kotlin/s630786217.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s630786217", "user_id": "u366280250"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, w) = readLine()!!.split(' ').map { it.toInt() }\n\n if (h == 1 && w == 1) {\n println(1)\n } else {\n println((h * w + 1) / 2)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 237, "memory_kb": 38208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s659042002", "group_id": "codeNet:p02742", "input_text": "fun main(args: Array) {\n val (a, b) = getLongs()\n println((a * b + 1) / 2)\n}\n\nfun getInt() = readLine()!!.toInt()\nfun getInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun getLong() = readLine()!!.toLong()\nfun getLongs() = readLine()!!.split(\" \").map { it.toLong() }", "language": "Kotlin", "metadata": {"date": 1584234648, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/Kotlin/s659042002.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s659042002", "user_id": "u895858420"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = getLongs()\n println((a * b + 1) / 2)\n}\n\nfun getInt() = readLine()!!.toInt()\nfun getInts() = readLine()!!.split(\" \").map { it.toInt() }\nfun getLong() = readLine()!!.toLong()\nfun getLongs() = readLine()!!.split(\" \").map { it.toLong() }", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 285, "cpu_time_ms": 240, "memory_kb": 38000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s682997588", "group_id": "codeNet:p02742", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val h = sc.nextLong()\n val w = sc.nextLong()\n\n println(pana2020b(h, w))\n}\n\nprivate fun pana2020b(h: Long, w: Long): Long {\n val h1 = h / 2L\n val h2 = h - h1\n val w1 = w / 2L\n val w2 = w - w1\n\n var ans = h1 * w1 + h2 * w2\n\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1584234592, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/Kotlin/s682997588.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s682997588", "user_id": "u323522006"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val h = sc.nextLong()\n val w = sc.nextLong()\n\n println(pana2020b(h, w))\n}\n\nprivate fun pana2020b(h: Long, w: Long): Long {\n val h1 = h / 2L\n val h2 = h - h1\n val w1 = w / 2L\n val w2 = w - w1\n\n var ans = h1 * w1 + h2 * w2\n\n return ans\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 181, "memory_kb": 29348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s961063426", "group_id": "codeNet:p02747", "input_text": "fun main(ar: Array?) {\n val i = System.`in`!!.reader(Charsets.US_ASCII).readLines()\n\n val il = i.flatMap { it.split(\" \") }.let { IntArray(it.size) { id -> it[id].toInt() } }\n val m = il[2]\n val b = il[1]\n val a = il[0]\n var min = 100000\n for (xi in (0 until m).reversed()) {\n var xxa = 3 + a + b + xi * 3 + 2\n val p1 = -il[xxa] + il[3 + a + il[--xxa] - 1] + il[3 + il[--xxa] - 1]\n if (p1 < min) {\n min = p1\n }\n }\n var ma = min\n for (aai in (3 until 3 + a).reversed()) {\n val ai = il[aai]\n if (ai < ma) {\n ma = ai\n }\n }\n if (ma < min) {\n var mb = min\n for (bbi in (3 + a until 3 + a + b).reversed()) {\n val bi = il[bbi]\n if (bi < mb) {\n mb = bi\n }\n }\n val mr = ma + mb\n if (mr < min) {\n print(mr)\n }\n }\n print(min)\n}", "language": "Kotlin", "metadata": {"date": 1583744820, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02747.html", "problem_id": "p02747", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02747/input.txt", "sample_output_relpath": "derived/input_output/data/p02747/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02747/Kotlin/s961063426.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s961063426", "user_id": "u033724502"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(ar: Array?) {\n val i = System.`in`!!.reader(Charsets.US_ASCII).readLines()\n\n val il = i.flatMap { it.split(\" \") }.let { IntArray(it.size) { id -> it[id].toInt() } }\n val m = il[2]\n val b = il[1]\n val a = il[0]\n var min = 100000\n for (xi in (0 until m).reversed()) {\n var xxa = 3 + a + b + xi * 3 + 2\n val p1 = -il[xxa] + il[3 + a + il[--xxa] - 1] + il[3 + il[--xxa] - 1]\n if (p1 < min) {\n min = p1\n }\n }\n var ma = min\n for (aai in (3 until 3 + a).reversed()) {\n val ai = il[aai]\n if (ai < ma) {\n ma = ai\n }\n }\n if (ma < min) {\n var mb = min\n for (bbi in (3 + a until 3 + a + b).reversed()) {\n val bi = il[bbi]\n if (bi < mb) {\n mb = bi\n }\n }\n val mr = ma + mb\n if (mr < min) {\n print(mr)\n }\n }\n print(min)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "sample_input": "hihi\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02747", "source_text": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 937, "cpu_time_ms": 211, "memory_kb": 33972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s302942036", "group_id": "codeNet:p02747", "input_text": "fun main(args: Array) {\n val S = readInputLine()\n var tmp = \"hi\"\n\n repeat(10) {\n if (tmp == S) {\n println(\"Yes\")\n return\n }\n tmp += \"hi\"\n }\n\n println(\"No\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1583715707, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02747.html", "problem_id": "p02747", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02747/input.txt", "sample_output_relpath": "derived/input_output/data/p02747/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02747/Kotlin/s302942036.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s302942036", "user_id": "u505558493"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readInputLine()\n var tmp = \"hi\"\n\n repeat(10) {\n if (tmp == S) {\n println(\"Yes\")\n return\n }\n tmp += \"hi\"\n }\n\n println(\"No\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "sample_input": "hihi\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02747", "source_text": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 262, "memory_kb": 29892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s180656138", "group_id": "codeNet:p02748", "input_text": "fun main(array: Array) {\n val (a, b, m) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = readLine()!!.split(\" \").map { it.toInt() }\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n var min = aList.min()!! + bList.min()!!\n repeat(m) {\n var temp = readLine()!!.split(\" \").map { it.toInt() }\n var tempMin = aList[temp[0]-1] + bList[temp[1]-1] - temp[2]\n min = if(tempMin <= min) {\n tempMin\n }\n else {\n min\n }\n }\n print(min)\n}", "language": "Kotlin", "metadata": {"date": 1589164077, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02748.html", "problem_id": "p02748", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02748/input.txt", "sample_output_relpath": "derived/input_output/data/p02748/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02748/Kotlin/s180656138.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180656138", "user_id": "u124119858"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(array: Array) {\n val (a, b, m) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = readLine()!!.split(\" \").map { it.toInt() }\n val bList = readLine()!!.split(\" \").map { it.toInt() }\n var min = aList.min()!! + bList.min()!!\n repeat(m) {\n var temp = readLine()!!.split(\" \").map { it.toInt() }\n var tempMin = aList[temp[0]-1] + bList[temp[1]-1] - temp[2]\n min = if(tempMin <= min) {\n tempMin\n }\n else {\n min\n }\n }\n print(min)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are visiting a large electronics store to buy a refrigerator and a microwave.\n\nThe store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \\le i \\le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \\le j \\le B ) is sold at b_j yen.\n\nYou have M discount tickets. With the i-th ticket ( 1 \\le i \\le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.\n\nYou are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\le A \\le 10^5\n\n1 \\le B \\le 10^5\n\n1 \\le M \\le 10^5\n\n1 \\le a_i , b_i , c_i \\le 10^5\n\n1 \\le x_i \\le A\n\n1 \\le y_i \\le B\n\nc_i \\le a_{x_i} + b_{y_i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B M\na_1 a_2 ... a_A\nb_1 b_2 ... b_B\nx_1 y_1 c_1\n\\vdots\nx_M y_M c_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 3 1\n3 3\n3 3 3\n1 2 1\n\nSample Output 1\n\n5\n\nWith the ticket, you can get the 1-st refrigerator and the 2-nd microwave for 3+3-1=5 yen.\n\nSample Input 2\n\n1 1 2\n10\n10\n1 1 5\n1 1 10\n\nSample Output 2\n\n10\n\nNote that you cannot use more than one ticket at a time.\n\nSample Input 3\n\n2 2 1\n3 5\n3 5\n2 2 2\n\nSample Output 3\n\n6\n\nYou can get the 1-st refrigerator and the 1-st microwave for 6 yen, which is the minimum amount to pay in this case.\nNote that using a ticket is optional.", "sample_input": "2 3 1\n3 3\n3 3 3\n1 2 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02748", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are visiting a large electronics store to buy a refrigerator and a microwave.\n\nThe store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \\le i \\le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \\le j \\le B ) is sold at b_j yen.\n\nYou have M discount tickets. With the i-th ticket ( 1 \\le i \\le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.\n\nYou are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\le A \\le 10^5\n\n1 \\le B \\le 10^5\n\n1 \\le M \\le 10^5\n\n1 \\le a_i , b_i , c_i \\le 10^5\n\n1 \\le x_i \\le A\n\n1 \\le y_i \\le B\n\nc_i \\le a_{x_i} + b_{y_i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B M\na_1 a_2 ... a_A\nb_1 b_2 ... b_B\nx_1 y_1 c_1\n\\vdots\nx_M y_M c_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 3 1\n3 3\n3 3 3\n1 2 1\n\nSample Output 1\n\n5\n\nWith the ticket, you can get the 1-st refrigerator and the 2-nd microwave for 3+3-1=5 yen.\n\nSample Input 2\n\n1 1 2\n10\n10\n1 1 5\n1 1 10\n\nSample Output 2\n\n10\n\nNote that you cannot use more than one ticket at a time.\n\nSample Input 3\n\n2 2 1\n3 5\n3 5\n2 2 2\n\nSample Output 3\n\n6\n\nYou can get the 1-st refrigerator and the 1-st microwave for 6 yen, which is the minimum amount to pay in this case.\nNote that using a ticket is optional.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 532, "cpu_time_ms": 952, "memory_kb": 102696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s000240367", "group_id": "codeNet:p02748", "input_text": "import java.lang.Math.*\nimport java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n var A = scn.nextInt()\n var B = scn.nextInt()\n var M = scn.nextInt()\n\n var a = IntArray(A+1)\n var b = IntArray(B+1)\n var minA = 1000000\n for(i in 1..A){\n a[i] = scn.nextInt()\n minA = min(minA, a[i])\n }\n var minB = 1000000\n for(i in 1..B){\n b[i] = scn.nextInt()\n minB = min(minB, b[i])\n }\n\n var min = minA + minB\n for(m in 1..M){\n val x = scn.nextInt()\n val y = scn.nextInt()\n val c = scn.nextInt()\n\n var sum = a[x] + b[y] - c\n min = min(min,sum)\n }\n println(min)\n}", "language": "Kotlin", "metadata": {"date": 1583717089, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02748.html", "problem_id": "p02748", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02748/input.txt", "sample_output_relpath": "derived/input_output/data/p02748/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02748/Kotlin/s000240367.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s000240367", "user_id": "u598554142"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.lang.Math.*\nimport java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n var A = scn.nextInt()\n var B = scn.nextInt()\n var M = scn.nextInt()\n\n var a = IntArray(A+1)\n var b = IntArray(B+1)\n var minA = 1000000\n for(i in 1..A){\n a[i] = scn.nextInt()\n minA = min(minA, a[i])\n }\n var minB = 1000000\n for(i in 1..B){\n b[i] = scn.nextInt()\n minB = min(minB, b[i])\n }\n\n var min = minA + minB\n for(m in 1..M){\n val x = scn.nextInt()\n val y = scn.nextInt()\n val c = scn.nextInt()\n\n var sum = a[x] + b[y] - c\n min = min(min,sum)\n }\n println(min)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are visiting a large electronics store to buy a refrigerator and a microwave.\n\nThe store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \\le i \\le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \\le j \\le B ) is sold at b_j yen.\n\nYou have M discount tickets. With the i-th ticket ( 1 \\le i \\le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.\n\nYou are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\le A \\le 10^5\n\n1 \\le B \\le 10^5\n\n1 \\le M \\le 10^5\n\n1 \\le a_i , b_i , c_i \\le 10^5\n\n1 \\le x_i \\le A\n\n1 \\le y_i \\le B\n\nc_i \\le a_{x_i} + b_{y_i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B M\na_1 a_2 ... a_A\nb_1 b_2 ... b_B\nx_1 y_1 c_1\n\\vdots\nx_M y_M c_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 3 1\n3 3\n3 3 3\n1 2 1\n\nSample Output 1\n\n5\n\nWith the ticket, you can get the 1-st refrigerator and the 2-nd microwave for 3+3-1=5 yen.\n\nSample Input 2\n\n1 1 2\n10\n10\n1 1 5\n1 1 10\n\nSample Output 2\n\n10\n\nNote that you cannot use more than one ticket at a time.\n\nSample Input 3\n\n2 2 1\n3 5\n3 5\n2 2 2\n\nSample Output 3\n\n6\n\nYou can get the 1-st refrigerator and the 1-st microwave for 6 yen, which is the minimum amount to pay in this case.\nNote that using a ticket is optional.", "sample_input": "2 3 1\n3 3\n3 3 3\n1 2 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02748", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are visiting a large electronics store to buy a refrigerator and a microwave.\n\nThe store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \\le i \\le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \\le j \\le B ) is sold at b_j yen.\n\nYou have M discount tickets. With the i-th ticket ( 1 \\le i \\le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.\n\nYou are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\le A \\le 10^5\n\n1 \\le B \\le 10^5\n\n1 \\le M \\le 10^5\n\n1 \\le a_i , b_i , c_i \\le 10^5\n\n1 \\le x_i \\le A\n\n1 \\le y_i \\le B\n\nc_i \\le a_{x_i} + b_{y_i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B M\na_1 a_2 ... a_A\nb_1 b_2 ... b_B\nx_1 y_1 c_1\n\\vdots\nx_M y_M c_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 3 1\n3 3\n3 3 3\n1 2 1\n\nSample Output 1\n\n5\n\nWith the ticket, you can get the 1-st refrigerator and the 2-nd microwave for 3+3-1=5 yen.\n\nSample Input 2\n\n1 1 2\n10\n10\n1 1 5\n1 1 10\n\nSample Output 2\n\n10\n\nNote that you cannot use more than one ticket at a time.\n\nSample Input 3\n\n2 2 1\n3 5\n3 5\n2 2 2\n\nSample Output 3\n\n6\n\nYou can get the 1-st refrigerator and the 1-st microwave for 6 yen, which is the minimum amount to pay in this case.\nNote that using a ticket is optional.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 683, "cpu_time_ms": 792, "memory_kb": 112072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s721625166", "group_id": "codeNet:p02753", "input_text": "fun main(args: Array) {\n val S = readLine()!!\n\n val tmp = S[0]\n\n for (i in 1 until S.length) {\n if (tmp != S[i]) {\n println(\"Yes\")\n return\n }\n }\n\n println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1592623864, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s721625166.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721625166", "user_id": "u932970230"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readLine()!!\n\n val tmp = S[0]\n\n for (i in 1 until S.length) {\n if (tmp != S[i]) {\n println(\"Yes\")\n return\n }\n }\n\n println(\"No\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 222, "cpu_time_ms": 104, "memory_kb": 34492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163870054", "group_id": "codeNet:p02753", "input_text": "fun main(){\n val s = readLine()!!;\n var a = false;\n var b = false;\n for( c in s){\n if(c == 'A'){\n a = true;\n }\n else{\n b = true;\n }\n }\n if(a && b) {\n println(\"Yes\");\n }\n else{\n println(\"No\");\n }\n}", "language": "Kotlin", "metadata": {"date": 1588149622, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s163870054.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s163870054", "user_id": "u933587574"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(){\n val s = readLine()!!;\n var a = false;\n var b = false;\n for( c in s){\n if(c == 'A'){\n a = true;\n }\n else{\n b = true;\n }\n }\n if(a && b) {\n println(\"Yes\");\n }\n else{\n println(\"No\");\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 161, "memory_kb": 31388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s799618100", "group_id": "codeNet:p02753", "input_text": "fun main(args: Array) {\n // Your code here!\n var S = readLine()\n \n if(S.equals(\"AAA\") or S.equals(\"BBB\")) println(\"No\")\n else println(\"Yes\")\n \n}\n", "language": "Kotlin", "metadata": {"date": 1584150961, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s799618100.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s799618100", "user_id": "u808976884"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n // Your code here!\n var S = readLine()\n \n if(S.equals(\"AAA\") or S.equals(\"BBB\")) println(\"No\")\n else println(\"Yes\")\n \n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 171, "cpu_time_ms": 212, "memory_kb": 33652}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s867196998", "group_id": "codeNet:p02753", "input_text": "import java.util.Scanner\n\nfun main() {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(if (s.any { it == s[0] }) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1583943648, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s867196998.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s867196998", "user_id": "u006493569"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main() {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(if (s.any { it == s[0] }) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 154, "memory_kb": 31260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s398501484", "group_id": "codeNet:p02753", "input_text": "fun main(args: Array) {\n val S = next()\n val ans = S != \"AAA\" && S != \"BBB\"\n println(if (ans) \"Yes\" else \"No\")\n}\nfun next() = readLine()!!\n", "language": "Kotlin", "metadata": {"date": 1583640385, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Kotlin/s398501484.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398501484", "user_id": "u043150661"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val S = next()\n val ans = S != \"AAA\" && S != \"BBB\"\n println(if (ans) \"Yes\" else \"No\")\n}\nfun next() = readLine()!!\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 156, "cpu_time_ms": 204, "memory_kb": 31748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s517311636", "group_id": "codeNet:p02754", "input_text": "import kotlin.math.min\n\n\nfun solve(N: Long, A: Long, B: Long) {\n val rep = N / (A + B)\n val sur = N % (A + B)\n println(rep * A + min(A, sur))\n}\n\nfun main() {\n// val S = readLine()!!\n// val N = readLine()!!.toInt()\n val (N, A, B) = readLine()!!.split(\" \").map { it.toLong() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(N, A, B)\n}", "language": "Kotlin", "metadata": {"date": 1595627367, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/Kotlin/s517311636.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517311636", "user_id": "u945228737"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import kotlin.math.min\n\n\nfun solve(N: Long, A: Long, B: Long) {\n val rep = N / (A + B)\n val sur = N % (A + B)\n println(rep * A + min(A, sur))\n}\n\nfun main() {\n// val S = readLine()!!\n// val N = readLine()!!.toInt()\n val (N, A, B) = readLine()!!.split(\" \").map { it.toLong() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(N, A, B)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 370, "cpu_time_ms": 127, "memory_kb": 36224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s032228666", "group_id": "codeNet:p02755", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n \n val x = (a * 100 + 7) / 8\n if (x / 10 == b) {\n println(x)\n return\n }\n \n val y = b * 10\n if (y * 8 / 100 == a) {\n println(y)\n return\n }\n \n println(-1)\n}\n", "language": "Kotlin", "metadata": {"date": 1585938865, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02755/input.txt", "sample_output_relpath": "derived/input_output/data/p02755/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02755/Kotlin/s032228666.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s032228666", "user_id": "u808976884"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map { it.toInt() }\n \n val x = (a * 100 + 7) / 8\n if (x / 10 == b) {\n println(x)\n return\n }\n \n val y = b * 10\n if (y * 8 / 100 == a) {\n println(y)\n return\n }\n \n println(-1)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 235, "memory_kb": 38240}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s865621712", "group_id": "codeNet:p02756", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n var S = scn.next()\n val Q = scn.nextInt()\n\n for(i in 1..Q){\n val T = scn.nextInt()\n\n if(T==1){\n var sb = StringBuffer(S)\n S = sb.reverse().toString()\n }else{\n val F = scn.nextInt()\n val C = scn.next()\n if(F==1){\n S = C + S\n }else{\n S = S + C\n }\n }\n }\n\n println(S)\n}", "language": "Kotlin", "metadata": {"date": 1583635086, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02756/input.txt", "sample_output_relpath": "derived/input_output/data/p02756/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02756/Kotlin/s865621712.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s865621712", "user_id": "u598554142"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scn = Scanner(System.`in`)\n var S = scn.next()\n val Q = scn.nextInt()\n\n for(i in 1..Q){\n val T = scn.nextInt()\n\n if(T==1){\n var sb = StringBuffer(S)\n S = sb.reverse().toString()\n }else{\n val F = scn.nextInt()\n val C = scn.next()\n if(F==1){\n S = C + S\n }else{\n S = S + C\n }\n }\n }\n\n println(S)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 503, "cpu_time_ms": 2111, "memory_kb": 119840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s657511729", "group_id": "codeNet:p02757", "input_text": "fun main(args: Array) = abc158e()\n\nfun abc158e() {\n val (n, p) = readLine()!!.split(' ').map { it.toInt() }\n val s = readLine()!!.toCharArray().map { it.toString().toInt() }.toIntArray()\n\n var answer = 0L\n\n when (10 % p) {\n 0 -> {\n var cnt = 1\n for (i in s) {\n if (i % 2 == 0 || i % 5 == 0) answer += cnt++\n }\n }\n else -> {\n val mods = IntArray(n + 1)\n var ten = 1\n for ((index, i) in s.withIndex()) {\n mods[index + 1] = (mods[index] + (i * ten % p)) % p\n ten *= 10\n ten %= p\n }\n\n val left = IntArray(p)\n for (m in mods) answer += left[m]++\n }\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1583704319, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02757.html", "problem_id": "p02757", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02757/input.txt", "sample_output_relpath": "derived/input_output/data/p02757/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02757/Kotlin/s657511729.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s657511729", "user_id": "u139478771"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) = abc158e()\n\nfun abc158e() {\n val (n, p) = readLine()!!.split(' ').map { it.toInt() }\n val s = readLine()!!.toCharArray().map { it.toString().toInt() }.toIntArray()\n\n var answer = 0L\n\n when (10 % p) {\n 0 -> {\n var cnt = 1\n for (i in s) {\n if (i % 2 == 0 || i % 5 == 0) answer += cnt++\n }\n }\n else -> {\n val mods = IntArray(n + 1)\n var ten = 1\n for ((index, i) in s.withIndex()) {\n mods[index + 1] = (mods[index] + (i * ten % p)) % p\n ten *= 10\n ten %= p\n }\n\n val left = IntArray(p)\n for (m in mods) answer += left[m]++\n }\n }\n\n println(answer)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "sample_input": "4 3\n3543\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02757", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 780, "cpu_time_ms": 360, "memory_kb": 43800}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s530951398", "group_id": "codeNet:p02760", "input_text": "fun main(args: Array) {\n \n val a = listOf(\n readLine()!!.split(\" \").map { it.toInt() },\n readLine()!!.split(\" \").map { it.toInt() },\n readLine()!!.split(\" \").map { it.toInt() }\n )\n val n = readLine()!!.toInt()\n val b = (1..n).map { readLine()!!.toInt() }\n \n/*\n val a = listOf(\n listOf(84, 97, 66),\n listOf(79, 89, 11),\n listOf(61, 59, 7)\n )\n \n val n = 7\n \n val b = listOf(\n 89,\n 7,\n 87,\n 79,\n 24,\n 84,\n 30\n )\n */\n \n val card = listOf(\n mutableListOf(false, false, false),\n mutableListOf(false, false, false),\n mutableListOf(false, false, false)\n )\n \n b.forEach { value ->\n val pos = findPos(a, value)\n pos?.let { (x, y) ->\n card[y][x] = true\n }\n }\n \n if (isBingo(card)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n \nfun findPos(list: List>, findValue: Int): Pair? {\n list.forEachIndexed { y, xlist ->\n val x = xlist.indexOfFirst { it == findValue }\n \n if (x != -1) {\n return Pair(x, y)\n }\n }\n \n return null\n}\n \nfun isBingo(card: List>): Boolean {\n val length = card.size\n \n // 横のチェック\n card.forEach { xlist ->\n if (xlist.none { !it }) return true\n }\n \n // 縦のチェック\n (0 until length).forEach { y ->\n if ((0 until length).map { x -> card[y][x] }.none { !it }) return true\n }\n \n // 斜めのチェック\n if ((0 until length).map { card[it][it] }.none { !it }) return true\n if ((0 until length).map { card[it][length - 1 - it] }.none { !it }) return true\n \n return false\n}", "language": "Kotlin", "metadata": {"date": 1597379347, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Kotlin/s530951398.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s530951398", "user_id": "u393104209"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n \n val a = listOf(\n readLine()!!.split(\" \").map { it.toInt() },\n readLine()!!.split(\" \").map { it.toInt() },\n readLine()!!.split(\" \").map { it.toInt() }\n )\n val n = readLine()!!.toInt()\n val b = (1..n).map { readLine()!!.toInt() }\n \n/*\n val a = listOf(\n listOf(84, 97, 66),\n listOf(79, 89, 11),\n listOf(61, 59, 7)\n )\n \n val n = 7\n \n val b = listOf(\n 89,\n 7,\n 87,\n 79,\n 24,\n 84,\n 30\n )\n */\n \n val card = listOf(\n mutableListOf(false, false, false),\n mutableListOf(false, false, false),\n mutableListOf(false, false, false)\n )\n \n b.forEach { value ->\n val pos = findPos(a, value)\n pos?.let { (x, y) ->\n card[y][x] = true\n }\n }\n \n if (isBingo(card)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n \nfun findPos(list: List>, findValue: Int): Pair? {\n list.forEachIndexed { y, xlist ->\n val x = xlist.indexOfFirst { it == findValue }\n \n if (x != -1) {\n return Pair(x, y)\n }\n }\n \n return null\n}\n \nfun isBingo(card: List>): Boolean {\n val length = card.size\n \n // 横のチェック\n card.forEach { xlist ->\n if (xlist.none { !it }) return true\n }\n \n // 縦のチェック\n (0 until length).forEach { y ->\n if ((0 until length).map { x -> card[y][x] }.none { !it }) return true\n }\n \n // 斜めのチェック\n if ((0 until length).map { card[it][it] }.none { !it }) return true\n if ((0 until length).map { card[it][length - 1 - it] }.none { !it }) return true\n \n return false\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1803, "cpu_time_ms": 131, "memory_kb": 39276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s629394192", "group_id": "codeNet:p02760", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = (0 until 3).map { (0 until 3).map { sc.next().toInt() } }\n val n = sc.nextInt()\n val b = (0 until n).map { sc.next().toInt() }\n println(problem157b(a, n, b))\n}\n\nfun problem157b(\n a: List>,\n n: Int,\n b: List\n): String {\n val b = b.toHashSet()\n val list = Array(3) { IntArray(3) { 0 } }\n for (i in 0 until 3) {\n for (j in 0 until 3) {\n val ij = a[i][j]\n if (b.contains(ij)) {\n list[i][j] = 1\n }\n }\n }\n return when {\n list[0][0] == 1 && list[0][1] == 1 && list[0][2] == 1 -> \"Yes\"\n list[1][0] == 1 && list[1][1] == 1 && list[1][2] == 1 -> \"Yes\"\n list[2][0] == 1 && list[2][1] == 1 && list[2][2] == 1 -> \"Yes\"\n\n list[0][0] == 1 && list[1][0] == 1 && list[2][0] == 1 -> \"Yes\"\n list[0][1] == 1 && list[1][1] == 1 && list[2][1] == 1 -> \"Yes\"\n list[0][2] == 1 && list[1][2] == 1 && list[2][2] == 1 -> \"Yes\"\n\n list[0][0] == 1 && list[1][1] == 1 && list[2][2] == 1 -> \"Yes\"\n list[0][2] == 1 && list[1][1] == 1 && list[2][0] == 1 -> \"Yes\"\n else -> \"No\"\n }\n}", "language": "Kotlin", "metadata": {"date": 1583115359, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Kotlin/s629394192.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629394192", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = (0 until 3).map { (0 until 3).map { sc.next().toInt() } }\n val n = sc.nextInt()\n val b = (0 until n).map { sc.next().toInt() }\n println(problem157b(a, n, b))\n}\n\nfun problem157b(\n a: List>,\n n: Int,\n b: List\n): String {\n val b = b.toHashSet()\n val list = Array(3) { IntArray(3) { 0 } }\n for (i in 0 until 3) {\n for (j in 0 until 3) {\n val ij = a[i][j]\n if (b.contains(ij)) {\n list[i][j] = 1\n }\n }\n }\n return when {\n list[0][0] == 1 && list[0][1] == 1 && list[0][2] == 1 -> \"Yes\"\n list[1][0] == 1 && list[1][1] == 1 && list[1][2] == 1 -> \"Yes\"\n list[2][0] == 1 && list[2][1] == 1 && list[2][2] == 1 -> \"Yes\"\n\n list[0][0] == 1 && list[1][0] == 1 && list[2][0] == 1 -> \"Yes\"\n list[0][1] == 1 && list[1][1] == 1 && list[2][1] == 1 -> \"Yes\"\n list[0][2] == 1 && list[1][2] == 1 && list[2][2] == 1 -> \"Yes\"\n\n list[0][0] == 1 && list[1][1] == 1 && list[2][2] == 1 -> \"Yes\"\n list[0][2] == 1 && list[1][1] == 1 && list[2][0] == 1 -> \"Yes\"\n else -> \"No\"\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1220, "cpu_time_ms": 188, "memory_kb": 31524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s306625480", "group_id": "codeNet:p02760", "input_text": "fun main(args: Array) {\n val a = readLine()!!.split(\" \").map(String::toInt)\n val b = readLine()!!.split(\" \").map(String::toInt)\n val c = readLine()!!.split(\" \").map(String::toInt)\n val n = readLine()!!.toInt()\n val card = a + b + c\n var stat = Array(3, { arrayOfNulls(3)})\n\n for (i in 1..n) {\n when (readLine()!!.toInt()) {\n card[0] -> stat[0][0] = 1\n card[1] -> stat[0][1] = 1\n card[2] -> stat[0][2] = 1\n card[3] -> stat[1][0] = 1\n card[4] -> stat[1][1] = 1\n card[5] -> stat[1][2] = 1\n card[6] -> stat[2][0] = 1\n card[7] -> stat[2][1] = 1\n card[8] -> stat[2][2] = 1\n }\n }\n\n if ((stat[0][0] == 1 && stat[0][1] == 1 && stat[0][2] == 1) ||\n (stat[1][0] == 1 && stat[1][1] == 1 && stat[1][2] == 1) ||\n (stat[2][0] == 1 && stat[2][1] == 1 && stat[2][2] == 1) ||\n (stat[0][0] == 1 && stat[1][0] == 1 && stat[2][0] == 1) ||\n (stat[0][1] == 1 && stat[1][1] == 1 && stat[2][1] == 1) ||\n (stat[0][2] == 1 && stat[1][2] == 1 && stat[2][2] == 1) ||\n (stat[0][0] == 1 && stat[1][1] == 1 && stat[2][2] == 1) ||\n (stat[0][2] == 1 && stat[1][1] == 1 && stat[2][0] == 1)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1583115356, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Kotlin/s306625480.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306625480", "user_id": "u288435405"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val a = readLine()!!.split(\" \").map(String::toInt)\n val b = readLine()!!.split(\" \").map(String::toInt)\n val c = readLine()!!.split(\" \").map(String::toInt)\n val n = readLine()!!.toInt()\n val card = a + b + c\n var stat = Array(3, { arrayOfNulls(3)})\n\n for (i in 1..n) {\n when (readLine()!!.toInt()) {\n card[0] -> stat[0][0] = 1\n card[1] -> stat[0][1] = 1\n card[2] -> stat[0][2] = 1\n card[3] -> stat[1][0] = 1\n card[4] -> stat[1][1] = 1\n card[5] -> stat[1][2] = 1\n card[6] -> stat[2][0] = 1\n card[7] -> stat[2][1] = 1\n card[8] -> stat[2][2] = 1\n }\n }\n\n if ((stat[0][0] == 1 && stat[0][1] == 1 && stat[0][2] == 1) ||\n (stat[1][0] == 1 && stat[1][1] == 1 && stat[1][2] == 1) ||\n (stat[2][0] == 1 && stat[2][1] == 1 && stat[2][2] == 1) ||\n (stat[0][0] == 1 && stat[1][0] == 1 && stat[2][0] == 1) ||\n (stat[0][1] == 1 && stat[1][1] == 1 && stat[2][1] == 1) ||\n (stat[0][2] == 1 && stat[1][2] == 1 && stat[2][2] == 1) ||\n (stat[0][0] == 1 && stat[1][1] == 1 && stat[2][2] == 1) ||\n (stat[0][2] == 1 && stat[1][1] == 1 && stat[2][0] == 1)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1326, "cpu_time_ms": 243, "memory_kb": 37724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s140965275", "group_id": "codeNet:p02760", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val b = Array(3) { IntArray(3) { 0 } }\n val check = Array(3) { Array(3) { false } }\n for (i in 0 until 3) {\n b[i] = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n }\n val N = readLine()!!.toInt()\n for (i in 0 until N) {\n val x = readLine()!!.toInt()\n for (j in 0 until 3) {\n for (k in 0 until 3) {\n if (b[j][k] == x) {\n check[j][k] = true\n }\n }\n }\n }\n val ok = (check[0][0] && check[0][1] && check[0][2])\n || (check[1][0] && check[1][1] && check[1][2])\n || (check[2][0] && check[2][1] && check[2][2])\n || (check[0][0] && check[1][0] && check[2][0])\n || (check[0][1] && check[1][1] && check[2][1])\n || (check[0][2] && check[1][2] && check[2][2])\n || (check[0][0] && check[1][1] && check[2][2])\n || (check[0][2] && check[1][1] && check[2][0])\n println(if (ok) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1583114721, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Kotlin/s140965275.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s140965275", "user_id": "u190507186"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val b = Array(3) { IntArray(3) { 0 } }\n val check = Array(3) { Array(3) { false } }\n for (i in 0 until 3) {\n b[i] = readLine()!!.split(' ').map { it.toInt() }.toIntArray()\n }\n val N = readLine()!!.toInt()\n for (i in 0 until N) {\n val x = readLine()!!.toInt()\n for (j in 0 until 3) {\n for (k in 0 until 3) {\n if (b[j][k] == x) {\n check[j][k] = true\n }\n }\n }\n }\n val ok = (check[0][0] && check[0][1] && check[0][2])\n || (check[1][0] && check[1][1] && check[1][2])\n || (check[2][0] && check[2][1] && check[2][2])\n || (check[0][0] && check[1][0] && check[2][0])\n || (check[0][1] && check[1][1] && check[2][1])\n || (check[0][2] && check[1][2] && check[2][2])\n || (check[0][0] && check[1][1] && check[2][2])\n || (check[0][2] && check[1][1] && check[2][0])\n println(if (ok) \"Yes\" else \"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1041, "cpu_time_ms": 236, "memory_kb": 36420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s820934794", "group_id": "codeNet:p02762", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M, K) = nextIntList()\n val UF = UnionFind(N)\n val G = IntArray(N + 1) { 0 }\n repeat(M) {\n val (a, b) = nextIntList()\n UF.unite(a, b)\n G[a]++\n G[b]++\n }\n val answers = IntArray(N + 1)\n for (i in 1..N) {\n answers[i] = UF.sizeOf(i) - G[i] - 1\n }\n repeat(K) {\n val (c, d) = nextIntList()\n if (UF.same(c, d)) {\n answers[c]--\n answers[d]--\n }\n }\n println(answers.drop(1).joinToString(\" \"))\n}\n\n// thanks to MulticolorWorld\nclass UnionFind(n: Int) {\n private val parent = IntArray(n + 1) { it }\n private val size = IntArray(n + 1) { 1 }\n\n fun root(x: Int): Int {\n return if (parent[x] == x) {\n x\n } else {\n parent[x] = root(parent[x])\n parent[x]\n }\n }\n\n fun unite(x: Int, y: Int) {\n val rx = root(x)\n val ry = root(y)\n if (rx != ry) {\n parent[rx] = ry\n// size[ry] += size[rx]\n }\n }\n\n fun same(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun sizeOf(x: Int): Int {\n return size[root(x)]\n }\n}", "language": "Kotlin", "metadata": {"date": 1593327393, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02762/input.txt", "sample_output_relpath": "derived/input_output/data/p02762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02762/Kotlin/s820934794.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s820934794", "user_id": "u860789370"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M, K) = nextIntList()\n val UF = UnionFind(N)\n val G = IntArray(N + 1) { 0 }\n repeat(M) {\n val (a, b) = nextIntList()\n UF.unite(a, b)\n G[a]++\n G[b]++\n }\n val answers = IntArray(N + 1)\n for (i in 1..N) {\n answers[i] = UF.sizeOf(i) - G[i] - 1\n }\n repeat(K) {\n val (c, d) = nextIntList()\n if (UF.same(c, d)) {\n answers[c]--\n answers[d]--\n }\n }\n println(answers.drop(1).joinToString(\" \"))\n}\n\n// thanks to MulticolorWorld\nclass UnionFind(n: Int) {\n private val parent = IntArray(n + 1) { it }\n private val size = IntArray(n + 1) { 1 }\n\n fun root(x: Int): Int {\n return if (parent[x] == x) {\n x\n } else {\n parent[x] = root(parent[x])\n parent[x]\n }\n }\n\n fun unite(x: Int, y: Int) {\n val rx = root(x)\n val ry = root(y)\n if (rx != ry) {\n parent[rx] = ry\n// size[ry] += size[rx]\n }\n }\n\n fun same(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun sizeOf(x: Int): Int {\n return size[root(x)]\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2007, "cpu_time_ms": 592, "memory_kb": 63940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s985680667", "group_id": "codeNet:p02762", "input_text": "fun main(args: Array) {\n val (n, m, k) = readIntegerList()\n val friendOrBlock = Array(n) { hashSetOf() }\n val unionFind = UnionFind(n)\n repeat(m) {\n val (a, b) = readIntegerList().map { it - 1 }\n friendOrBlock[a].add(b)\n friendOrBlock[b].add(a)\n unionFind.unite(a, b)\n }\n\n repeat(k) {\n val (a, b) = readIntegerList().map { it - 1 }\n if (unionFind.sameRoot(a, b)) {\n friendOrBlock[a].add(b)\n friendOrBlock[b].add(a)\n }\n }\n\n val ans = IntArray(n)\n repeat(n) {\n ans[it] = unionFind.getSize(it) - 1 - friendOrBlock[it].filter { true }.size\n }\n println(ans.joinToString(\" \"))\n}\n\n/** Union find 0 ~ (n - 1) */\nclass UnionFind(n: Int) {\n val parent = IntArray(n) { -1 }\n\n /** O(α(n)) */\n fun rootOf(x: Int): Int {\n if (parent[x] < 0) return x\n\n parent[x] = rootOf(parent[x])\n return parent[x]\n }\n\n /** O(α(n)) */\n fun sameRoot(x: Int, y: Int) = rootOf(x) == rootOf(y)\n\n /** O(α(n)) */\n fun unite(x: Int, y: Int): Boolean {\n var x = rootOf(x)\n var y = rootOf(y)\n if (x == y) return false\n if (parent[x] > parent[y]) {\n val tmp = x\n x = y\n y = tmp\n }\n parent[x] += parent[y]\n parent[y] = x\n return true\n }\n\n /** O(α(n)) */\n fun getSize(x: Int) = -parent[rootOf(x)]\n};\n\n\n\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1584820493, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02762/input.txt", "sample_output_relpath": "derived/input_output/data/p02762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02762/Kotlin/s985680667.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s985680667", "user_id": "u784448849"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m, k) = readIntegerList()\n val friendOrBlock = Array(n) { hashSetOf() }\n val unionFind = UnionFind(n)\n repeat(m) {\n val (a, b) = readIntegerList().map { it - 1 }\n friendOrBlock[a].add(b)\n friendOrBlock[b].add(a)\n unionFind.unite(a, b)\n }\n\n repeat(k) {\n val (a, b) = readIntegerList().map { it - 1 }\n if (unionFind.sameRoot(a, b)) {\n friendOrBlock[a].add(b)\n friendOrBlock[b].add(a)\n }\n }\n\n val ans = IntArray(n)\n repeat(n) {\n ans[it] = unionFind.getSize(it) - 1 - friendOrBlock[it].filter { true }.size\n }\n println(ans.joinToString(\" \"))\n}\n\n/** Union find 0 ~ (n - 1) */\nclass UnionFind(n: Int) {\n val parent = IntArray(n) { -1 }\n\n /** O(α(n)) */\n fun rootOf(x: Int): Int {\n if (parent[x] < 0) return x\n\n parent[x] = rootOf(parent[x])\n return parent[x]\n }\n\n /** O(α(n)) */\n fun sameRoot(x: Int, y: Int) = rootOf(x) == rootOf(y)\n\n /** O(α(n)) */\n fun unite(x: Int, y: Int): Boolean {\n var x = rootOf(x)\n var y = rootOf(y)\n if (x == y) return false\n if (parent[x] > parent[y]) {\n val tmp = x\n x = y\n y = tmp\n }\n parent[x] += parent[y]\n parent[y] = x\n return true\n }\n\n /** O(α(n)) */\n fun getSize(x: Int) = -parent[rootOf(x)]\n};\n\n\n\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1745, "cpu_time_ms": 1358, "memory_kb": 138340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s231971603", "group_id": "codeNet:p02762", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val k = sc.nextInt()\n val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() }\n val cd = (0 until k).map { sc.next().toInt() to sc.next().toInt() }\n println(problem157d(n, m, k, ab, cd))\n}\n\nfun problem157d(\n n: Int,\n m: Int,\n k: Int,\n ab: List>,\n cd: List>\n): String {\n class UnionFind(n: Int) {\n val par = (0..n).toMutableList()\n val size = IntArray(n + 1) { 1 }\n\n fun root(x: Int): Int {\n if (par[x] == x) return x\n return root(par[x])\n }\n\n fun merge(x: Int, y: Int) {\n val rx = root(x)\n val ry = root(y)\n if (rx == ry) return\n par[rx] = ry\n size[rx] =+ size[ry]\n }\n\n fun isSame(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun size(x: Int) = par[root(x)]\n\n override fun toString(): String {\n return par.toString()\n }\n }\n\n val dame = Array>(n + 1) { mutableSetOf() }\n val uf = UnionFind(n)\n for (i in 0 until m) {\n val (a, b) = ab[i]\n dame[a].add(b)\n dame[b].add(a)\n uf.merge(a, b)\n }\n for (i in 0 until k) {\n val (c, d) = cd[i]\n if (!uf.isSame(c, d)) continue\n dame[c].add(d)\n dame[d].add(c)\n }\n val ans = mutableListOf()\n for (i in 1..n) {\n val mem = uf.size(i) - 1\n ans.add(mem - dame[i].size)\n }\n return ans.joinToString(\" \")\n}", "language": "Kotlin", "metadata": {"date": 1583361518, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02762/input.txt", "sample_output_relpath": "derived/input_output/data/p02762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02762/Kotlin/s231971603.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s231971603", "user_id": "u073232808"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val k = sc.nextInt()\n val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() }\n val cd = (0 until k).map { sc.next().toInt() to sc.next().toInt() }\n println(problem157d(n, m, k, ab, cd))\n}\n\nfun problem157d(\n n: Int,\n m: Int,\n k: Int,\n ab: List>,\n cd: List>\n): String {\n class UnionFind(n: Int) {\n val par = (0..n).toMutableList()\n val size = IntArray(n + 1) { 1 }\n\n fun root(x: Int): Int {\n if (par[x] == x) return x\n return root(par[x])\n }\n\n fun merge(x: Int, y: Int) {\n val rx = root(x)\n val ry = root(y)\n if (rx == ry) return\n par[rx] = ry\n size[rx] =+ size[ry]\n }\n\n fun isSame(x: Int, y: Int): Boolean {\n return root(x) == root(y)\n }\n\n fun size(x: Int) = par[root(x)]\n\n override fun toString(): String {\n return par.toString()\n }\n }\n\n val dame = Array>(n + 1) { mutableSetOf() }\n val uf = UnionFind(n)\n for (i in 0 until m) {\n val (a, b) = ab[i]\n dame[a].add(b)\n dame[b].add(a)\n uf.merge(a, b)\n }\n for (i in 0 until k) {\n val (c, d) = cd[i]\n if (!uf.isSame(c, d)) continue\n dame[c].add(d)\n dame[d].add(c)\n }\n val ans = mutableListOf()\n for (i in 1..n) {\n val mem = uf.size(i) - 1\n ans.add(mem - dame[i].size)\n }\n return ans.joinToString(\" \")\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1655, "cpu_time_ms": 2111, "memory_kb": 111956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s851496931", "group_id": "codeNet:p02762", "input_text": "fun main(args: Array) {\n val (N, M, K) = listOfInt()\n val U = UnionFind(N)\n val F = Array>(N) { mutableListOf() }\n val G = Array>(N) { mutableListOf() }\n repeat(M) {\n val (a, b) = listOfInt(-1)\n U.union(a, b); U.union(b, a)\n F[a].add(b); F[b].add(a)\n }\n repeat(K) {\n val (c, d) = listOfInt(-1)\n G[c].add(d)\n G[d].add(c)\n }\n val ans = IntArray(N)\n repeat(N) { n ->\n var f = 0\n repeat(N) { m ->\n if (n != m) {\n if (!F[n].contains(m) && !G[n].contains(m)) {\n if (U.find(n) == U.find(m)) f += 1\n }\n }\n }\n ans[n] = f\n }\n\n println(ans.joinToString(separator = \" \"))\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nclass UnionFind(n: Int) {\n var rank: IntArray\n var par: IntArray\n var size: IntArray\n\n init {\n this.rank = IntArray(n) { 0 }\n this.par = IntArray(n) { it }\n this.size = IntArray(n) { 1 }\n }\n\n fun union(x: Int, y: Int): Boolean {\n var rx = this.root(x)\n var ry = this.root(y)\n if (rx == ry) return false\n\n if (this.rank[rx] < this.rank[ry]) {\n val w = rx.toInt()\n rx = ry\n ry = w\n } else if (this.rank[rx] == this.rank[ry]) {\n this.rank[rx] += 1\n }\n this.par[ry] = rx.toInt()\n this.size[rx] += this.size[ry]\n return true\n }\n\n fun find(x: Int): Int {\n if (this.par[x] == x) return x\n else {\n this.par[x] = this.find(this.par[x])\n return this.par[x]\n }\n }\n fun isSame(x: Int, y: Int): Boolean = this.root(x) == this.root(y)\n fun getSize(x: Int): Int = this.size[this.find(x)]\n fun root(x: Int): Int = this.find(x)\n fun unite(x: Int, y: Int): Boolean = this.union(x, y)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1583119748, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02762/input.txt", "sample_output_relpath": "derived/input_output/data/p02762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02762/Kotlin/s851496931.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s851496931", "user_id": "u043150661"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M, K) = listOfInt()\n val U = UnionFind(N)\n val F = Array>(N) { mutableListOf() }\n val G = Array>(N) { mutableListOf() }\n repeat(M) {\n val (a, b) = listOfInt(-1)\n U.union(a, b); U.union(b, a)\n F[a].add(b); F[b].add(a)\n }\n repeat(K) {\n val (c, d) = listOfInt(-1)\n G[c].add(d)\n G[d].add(c)\n }\n val ans = IntArray(N)\n repeat(N) { n ->\n var f = 0\n repeat(N) { m ->\n if (n != m) {\n if (!F[n].contains(m) && !G[n].contains(m)) {\n if (U.find(n) == U.find(m)) f += 1\n }\n }\n }\n ans[n] = f\n }\n\n println(ans.joinToString(separator = \" \"))\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nclass UnionFind(n: Int) {\n var rank: IntArray\n var par: IntArray\n var size: IntArray\n\n init {\n this.rank = IntArray(n) { 0 }\n this.par = IntArray(n) { it }\n this.size = IntArray(n) { 1 }\n }\n\n fun union(x: Int, y: Int): Boolean {\n var rx = this.root(x)\n var ry = this.root(y)\n if (rx == ry) return false\n\n if (this.rank[rx] < this.rank[ry]) {\n val w = rx.toInt()\n rx = ry\n ry = w\n } else if (this.rank[rx] == this.rank[ry]) {\n this.rank[rx] += 1\n }\n this.par[ry] = rx.toInt()\n this.size[rx] += this.size[ry]\n return true\n }\n\n fun find(x: Int): Int {\n if (this.par[x] == x) return x\n else {\n this.par[x] = this.find(this.par[x])\n return this.par[x]\n }\n }\n fun isSame(x: Int, y: Int): Boolean = this.root(x) == this.root(y)\n fun getSize(x: Int): Int = this.size[this.find(x)]\n fun root(x: Int): Int = this.find(x)\n fun unite(x: Int, y: Int): Boolean = this.union(x, y)\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2062, "cpu_time_ms": 2111, "memory_kb": 153592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s822265983", "group_id": "codeNet:p02763", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val segTree = SegmentTree(n)\n val s = br.readLine()!!.toCharArray()\n val q = readInteger()\n\n for ((i, c) in s.withIndex()) {\n segTree.update(i, c)\n }\n\n repeat(q) {\n val (d, e, f) = readStringList()\n\n if (d == \"1\") {\n val i = e.toInt() - 1\n val c = f.first()\n segTree.update(i, c)\n } else {\n val l = e.toInt() - 1\n val r = f.toInt() - 1\n val tmp = segTree.query(l, r + 1)\n out.println(tmp.size)\n }\n }\n}\n\nclass SegmentTree(length: Int) {\n private val tree: Array>\n private val leafCount: Int\n\n init {\n var cap = 0\n var last = 1\n while (true) {\n cap += last\n if (last >= length) break\n last *= 2\n }\n\n if (length == 0) cap = 0\n leafCount = last\n tree = Array(cap) { emptySet() }\n }\n\n fun debug() {\n for ((v, i ) in tree.withIndex()) {\n out.print(v to i)\n if (v in listOf(0, 2, 6, 14)) out.println()\n }\n out.println()\n }\n\n fun update(i: Int, v: Char) {\n var nodeIndex = tree.size - leafCount + i\n tree[nodeIndex] = setOf(v)\n while (nodeIndex > 0) {\n nodeIndex = (nodeIndex - 1) / 2\n val a = tree[nodeIndex * 2 + 1]\n val b = tree[nodeIndex * 2 + 2]\n tree[nodeIndex] = a union b\n }\n }\n\n fun query(l: Int, r: Int, nodeIndex: Int = 0, currentL: Int = 0, currentR: Int = leafCount): Set {\n if (currentR <= l || r <= currentL) return emptySet()\n if (l <= currentL && currentR <= r) return tree[nodeIndex]\n val a = query(l, r, nodeIndex * 2 + 1, currentL, (currentL + currentR) / 2)\n val b = query(l, r, nodeIndex * 2 + 2, (currentL + currentR) / 2, currentR)\n return a union b\n }\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1599247583, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Kotlin/s822265983.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s822265983", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val segTree = SegmentTree(n)\n val s = br.readLine()!!.toCharArray()\n val q = readInteger()\n\n for ((i, c) in s.withIndex()) {\n segTree.update(i, c)\n }\n\n repeat(q) {\n val (d, e, f) = readStringList()\n\n if (d == \"1\") {\n val i = e.toInt() - 1\n val c = f.first()\n segTree.update(i, c)\n } else {\n val l = e.toInt() - 1\n val r = f.toInt() - 1\n val tmp = segTree.query(l, r + 1)\n out.println(tmp.size)\n }\n }\n}\n\nclass SegmentTree(length: Int) {\n private val tree: Array>\n private val leafCount: Int\n\n init {\n var cap = 0\n var last = 1\n while (true) {\n cap += last\n if (last >= length) break\n last *= 2\n }\n\n if (length == 0) cap = 0\n leafCount = last\n tree = Array(cap) { emptySet() }\n }\n\n fun debug() {\n for ((v, i ) in tree.withIndex()) {\n out.print(v to i)\n if (v in listOf(0, 2, 6, 14)) out.println()\n }\n out.println()\n }\n\n fun update(i: Int, v: Char) {\n var nodeIndex = tree.size - leafCount + i\n tree[nodeIndex] = setOf(v)\n while (nodeIndex > 0) {\n nodeIndex = (nodeIndex - 1) / 2\n val a = tree[nodeIndex * 2 + 1]\n val b = tree[nodeIndex * 2 + 2]\n tree[nodeIndex] = a union b\n }\n }\n\n fun query(l: Int, r: Int, nodeIndex: Int = 0, currentL: Int = 0, currentR: Int = leafCount): Set {\n if (currentR <= l || r <= currentL) return emptySet()\n if (l <= currentL && currentR <= r) return tree[nodeIndex]\n val a = query(l, r, nodeIndex * 2 + 1, currentL, (currentL + currentR) / 2)\n val b = query(l, r, nodeIndex * 2 + 2, (currentL + currentR) / 2, currentR)\n return a union b\n }\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2564, "cpu_time_ms": 2213, "memory_kb": 190640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s311448123", "group_id": "codeNet:p02763", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.cos\nimport kotlin.math.max\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val s = br.readLine()!!.toCharArray()\n val q = readInteger()\n\n val segTree = SegmentTree(s.size)\n for ((i, c) in s.withIndex()) {\n segTree.update(i, c)\n }\n\n repeat(q) {\n val (a, i, c) = readStringList()\n if (a == \"1\") {\n segTree.update(i.toInt() - 1, c[0])\n } else {\n val l = i.toInt() - 1\n val r = c.toInt()\n val v = segTree.query(l, r)\n// segTree.debug()\n// out.println()\n out.println(v.size)\n\n }\n }\n}\n\nclass SegmentTree(private val length: Int) {\n val tree = Array(capacity(length)) { emptySet() }\n\n fun debug() {\n for ((v, i ) in tree.withIndex()) {\n out.println(v to i)\n if (v in listOf(0, 2, 6, 14)) out.println()\n }\n }\n\n fun update(i: Int, v: Char) {\n var nodeIndex = tree.size - length + i - 1\n tree[nodeIndex] = setOf(v)\n while (nodeIndex > 0) {\n nodeIndex = (nodeIndex - 1) / 2\n val a = tree[nodeIndex * 2 + 1]\n val b = tree[nodeIndex * 2 + 2]\n tree[nodeIndex] = a union b\n }\n }\n\n fun query(l: Int, r: Int, nodeIndex: Int = 0, currentL: Int = 0, currentR: Int = (capacity(length) + 1) / 2): Set {\n if (currentR <= l || r <= currentL) return emptySet()\n if (l <= currentL && currentR <= r) {\n// out.println(nodeIndex)\n return tree[nodeIndex]\n }\n val a = query(l, r, nodeIndex * 2 + 1, currentL, (currentL + currentR) / 2)\n val b = query(l, r, nodeIndex * 2 + 2, (currentL + currentR) / 2, currentR)\n return a union b\n }\n\n fun capacity(length: Int): Int {\n var ans = 2\n while (ans < length * 2 - 1) ans *= 2\n return ans - 1\n }\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1598858010, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Kotlin/s311448123.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s311448123", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\nimport kotlin.math.abs\nimport kotlin.math.cos\nimport kotlin.math.max\nimport kotlin.math.min\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val n = readInteger()\n val s = br.readLine()!!.toCharArray()\n val q = readInteger()\n\n val segTree = SegmentTree(s.size)\n for ((i, c) in s.withIndex()) {\n segTree.update(i, c)\n }\n\n repeat(q) {\n val (a, i, c) = readStringList()\n if (a == \"1\") {\n segTree.update(i.toInt() - 1, c[0])\n } else {\n val l = i.toInt() - 1\n val r = c.toInt()\n val v = segTree.query(l, r)\n// segTree.debug()\n// out.println()\n out.println(v.size)\n\n }\n }\n}\n\nclass SegmentTree(private val length: Int) {\n val tree = Array(capacity(length)) { emptySet() }\n\n fun debug() {\n for ((v, i ) in tree.withIndex()) {\n out.println(v to i)\n if (v in listOf(0, 2, 6, 14)) out.println()\n }\n }\n\n fun update(i: Int, v: Char) {\n var nodeIndex = tree.size - length + i - 1\n tree[nodeIndex] = setOf(v)\n while (nodeIndex > 0) {\n nodeIndex = (nodeIndex - 1) / 2\n val a = tree[nodeIndex * 2 + 1]\n val b = tree[nodeIndex * 2 + 2]\n tree[nodeIndex] = a union b\n }\n }\n\n fun query(l: Int, r: Int, nodeIndex: Int = 0, currentL: Int = 0, currentR: Int = (capacity(length) + 1) / 2): Set {\n if (currentR <= l || r <= currentL) return emptySet()\n if (l <= currentL && currentR <= r) {\n// out.println(nodeIndex)\n return tree[nodeIndex]\n }\n val a = query(l, r, nodeIndex * 2 + 1, currentL, (currentL + currentR) / 2)\n val b = query(l, r, nodeIndex * 2 + 2, (currentL + currentR) / 2, currentR)\n return a union b\n }\n\n fun capacity(length: Int): Int {\n var ans = 2\n while (ans < length * 2 - 1) ans *= 2\n return ans - 1\n }\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2589, "cpu_time_ms": 2210, "memory_kb": 190912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s327203620", "group_id": "codeNet:p02765", "input_text": "fun main (args:Array) {\n val (trytime, hrate) = readLine()!!.split(\" \").map(String::toInt)\n if(trytime >= 10){\n print(hrate)\n return\n }\n val nrate = 100 * (10-trytime)\n print(hrate + nrate)\n}\n", "language": "Kotlin", "metadata": {"date": 1593180482, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/Kotlin/s327203620.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s327203620", "user_id": "u838133978"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "fun main (args:Array) {\n val (trytime, hrate) = readLine()!!.split(\" \").map(String::toInt)\n if(trytime >= 10){\n print(hrate)\n return\n }\n val nrate = 100 * (10-trytime)\n print(hrate + nrate)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 107, "memory_kb": 36312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s091349091", "group_id": "codeNet:p02767", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val points = readLine()!!.split(\" \").map { it.toInt() }\n var answer = Double.MAX_VALUE\n for (i in points.min()!!..points.max()!!) {\n var candidate = 0.0\n for (j in 0 until n) {\n candidate += Math.pow(points[j]-i.toDouble(), 2.0)\n }\n answer = Math.min(candidate, answer)\n }\n println(answer.toInt())\n}\n", "language": "Kotlin", "metadata": {"date": 1584761641, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02767/input.txt", "sample_output_relpath": "derived/input_output/data/p02767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02767/Kotlin/s091349091.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s091349091", "user_id": "u396701320"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val points = readLine()!!.split(\" \").map { it.toInt() }\n var answer = Double.MAX_VALUE\n for (i in points.min()!!..points.max()!!) {\n var candidate = 0.0\n for (j in 0 until n) {\n candidate += Math.pow(points[j]-i.toDouble(), 2.0)\n }\n answer = Math.min(candidate, answer)\n }\n println(answer.toInt())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 253, "memory_kb": 37692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s500556104", "group_id": "codeNet:p02767", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val x = (0 until n).map { sc.nextInt() }\n var minv: Long = 9223372036854775807\n var xlast = x[n - 1]\n for (i in 1..xlast) {\n var res: Long = 0\n for (j in x.indices) {\n res += (x[j] - i) * (x[j] - i)\n }\n minv = Math.min(res, minv)\n }\n println(minv)\n}", "language": "Kotlin", "metadata": {"date": 1582425353, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02767/input.txt", "sample_output_relpath": "derived/input_output/data/p02767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02767/Kotlin/s500556104.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s500556104", "user_id": "u369142620"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val x = (0 until n).map { sc.nextInt() }\n var minv: Long = 9223372036854775807\n var xlast = x[n - 1]\n for (i in 1..xlast) {\n var res: Long = 0\n for (j in x.indices) {\n res += (x[j] - i) * (x[j] - i)\n }\n minv = Math.min(res, minv)\n }\n println(minv)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 418, "cpu_time_ms": 228, "memory_kb": 31648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163120499", "group_id": "codeNet:p02768", "input_text": "fun modCnr(n: Long, r: Long, mod: Long): Long {\n val l: Long = n - r + 1\n var nt = 1L\n var i = 0\n while (n - i >= l) {\n nt = (nt * (n - i)) % mod\n i++\n }\n\n var rt = 1L\n var j = 0\n while (j < r) {\n rt = (rt * (r - j)) % mod\n j++\n }\n return (nt * modPow(rt, mod - 2, mod)) % mod\n}\n\nfun modPow(n: Long, ex: Long, mod: Long): Long {\n var x = n\n var remain = ex\n var result = 1L\n while (remain > 0) {\n if (remain % 2L == 1L) {\n result = (result * x) % mod\n }\n x = (x * x) % mod\n remain /= 2\n }\n return result\n}\n\nfun main(args: Array) {\n val (n, a, b) = readLine()?.split(\" \")?.map(String::toLong) ?: return\n val mod = 1000000007L\n\n val np = modPow(2, n, mod)\n val ncra = modCnr(n, a, mod)\n val ncrb = modCnr(n, b, mod)\n\n println((np - ncra - ncrb - 1 + mod) % mod)\n}\n", "language": "Kotlin", "metadata": {"date": 1587157959, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/Kotlin/s163120499.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s163120499", "user_id": "u979429407"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun modCnr(n: Long, r: Long, mod: Long): Long {\n val l: Long = n - r + 1\n var nt = 1L\n var i = 0\n while (n - i >= l) {\n nt = (nt * (n - i)) % mod\n i++\n }\n\n var rt = 1L\n var j = 0\n while (j < r) {\n rt = (rt * (r - j)) % mod\n j++\n }\n return (nt * modPow(rt, mod - 2, mod)) % mod\n}\n\nfun modPow(n: Long, ex: Long, mod: Long): Long {\n var x = n\n var remain = ex\n var result = 1L\n while (remain > 0) {\n if (remain % 2L == 1L) {\n result = (result * x) % mod\n }\n x = (x * x) % mod\n remain /= 2\n }\n return result\n}\n\nfun main(args: Array) {\n val (n, a, b) = readLine()?.split(\" \")?.map(String::toLong) ?: return\n val mod = 1000000007L\n\n val np = modPow(2, n, mod)\n val ncra = modCnr(n, a, mod)\n val ncrb = modCnr(n, b, mod)\n\n println((np - ncra - ncrb - 1 + mod) % mod)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 903, "cpu_time_ms": 254, "memory_kb": 38120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s570072198", "group_id": "codeNet:p02768", "input_text": "const val MOD = 1000000007L\nfun main(args: Array) {\n val (N, A, B) = listOfInt()\n fun pow2(n: Int): ModInt {\n if (n == 0) return ModInt(1)\n var x = pow2(n / 2)\n x *= x\n if (n % 2 == 1) x *= 2\n return x\n }\n fun C(n: Int, a: Int): ModInt {\n var x = ModInt(1)\n var y = ModInt(1)\n repeat(a) { i ->\n x *= n - i\n y *= i + 1\n }\n return x / y\n }\n var ans = pow2(N)\n ans -= 1\n ans -= C(N, A)\n ans -= C(N, B)\n println(ans.toString())\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\n\n\ndata class ModInt(private var v: Long) {\n companion object {\n private const val MOD = 1000000007L\n }\n init {\n if (v >= MOD) v %= MOD\n }\n constructor(n: Int): this(n.toLong())\n operator fun plus(other: Int): ModInt {\n val x = v + other\n if (x >= MOD) {\n return ModInt(x - MOD)\n }\n return ModInt(x)\n }\n operator fun minus(other: Int): ModInt {\n val x = v + MOD - other\n if (x >= MOD) {\n return ModInt(x - MOD)\n }\n return ModInt(x)\n }\n operator fun minus(other: ModInt): ModInt {\n val x = v + MOD - other.v\n if (x >= MOD) {\n return ModInt(x - MOD)\n }\n return ModInt(x)\n }\n operator fun times(other: Int): ModInt {\n return ModInt(v * other % MOD)\n }\n operator fun times(other: ModInt): ModInt {\n return ModInt(v * other.v % MOD)\n }\n operator fun div(other: ModInt): ModInt {\n return ModInt(v * pow(other.v, MOD - 2) % MOD)\n }\n private fun pow(a: Long, b: Long): Long {\n if (b == 0L) return 1L\n if (b % 2L == 0L) {\n val d = pow(a, b / 2)\n return d * d % MOD\n }\n return a * pow(a, b - 1) % MOD\n }\n override fun toString(): String {\n return v.toString()\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1582574366, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/Kotlin/s570072198.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s570072198", "user_id": "u043150661"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "const val MOD = 1000000007L\nfun main(args: Array) {\n val (N, A, B) = listOfInt()\n fun pow2(n: Int): ModInt {\n if (n == 0) return ModInt(1)\n var x = pow2(n / 2)\n x *= x\n if (n % 2 == 1) x *= 2\n return x\n }\n fun C(n: Int, a: Int): ModInt {\n var x = ModInt(1)\n var y = ModInt(1)\n repeat(a) { i ->\n x *= n - i\n y *= i + 1\n }\n return x / y\n }\n var ans = pow2(N)\n ans -= 1\n ans -= C(N, A)\n ans -= C(N, B)\n println(ans.toString())\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\n\n\ndata class ModInt(private var v: Long) {\n companion object {\n private const val MOD = 1000000007L\n }\n init {\n if (v >= MOD) v %= MOD\n }\n constructor(n: Int): this(n.toLong())\n operator fun plus(other: Int): ModInt {\n val x = v + other\n if (x >= MOD) {\n return ModInt(x - MOD)\n }\n return ModInt(x)\n }\n operator fun minus(other: Int): ModInt {\n val x = v + MOD - other\n if (x >= MOD) {\n return ModInt(x - MOD)\n }\n return ModInt(x)\n }\n operator fun minus(other: ModInt): ModInt {\n val x = v + MOD - other.v\n if (x >= MOD) {\n return ModInt(x - MOD)\n }\n return ModInt(x)\n }\n operator fun times(other: Int): ModInt {\n return ModInt(v * other % MOD)\n }\n operator fun times(other: ModInt): ModInt {\n return ModInt(v * other.v % MOD)\n }\n operator fun div(other: ModInt): ModInt {\n return ModInt(v * pow(other.v, MOD - 2) % MOD)\n }\n private fun pow(a: Long, b: Long): Long {\n if (b == 0L) return 1L\n if (b % 2L == 0L) {\n val d = pow(a, b / 2)\n return d * d % MOD\n }\n return a * pow(a, b - 1) % MOD\n }\n override fun toString(): String {\n return v.toString()\n }\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2041, "cpu_time_ms": 299, "memory_kb": 42936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s079855590", "group_id": "codeNet:p02768", "input_text": "fun main(args: Array) {\n val (N, A, B) = readLine()!!.split(\" \").map(String::toLong)\n val ans = MInt(2).pow(N) - MInt(1) - combination(N, A) - combination(N, B)\n println(ans)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a += b\n return a\n }\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a -= b\n return a\n }\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a *= b\n return a\n }\n\n operator fun div(b: MInt): MInt {\n val a = MInt(v)\n a /= b\n return a\n }\n\n operator fun plusAssign(b: MInt) {\n v += b.v\n if (v >= MOD) v -= MOD\n }\n\n operator fun minusAssign(b: MInt) {\n v -= b.v\n if (v < 0) v += MOD\n }\n\n operator fun timesAssign(b: MInt) {\n v *= b.v\n v %= MOD\n }\n\n operator fun divAssign(b: MInt) {\n this *= b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(N: Long): MInt {\n var ans = MInt(1)\n var a = this\n var n = N\n while (n > 0) {\n if (n.and(1) == 1L) {\n ans = ans * a\n }\n a = a * a\n n = n.shr(1)\n }\n return ans\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}\n\nfun combination(n: Long, k: Long): MInt {\n var a = MInt(1)\n var b = MInt(1)\n val min = Math.min(n - k, k)\n for (i in n - min + 1..n) {\n a = a * MInt(i)\n }\n for (i in 1..min) {\n b = b * MInt(i)\n }\n return a / b\n}", "language": "Kotlin", "metadata": {"date": 1582410041, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/Kotlin/s079855590.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079855590", "user_id": "u860789370"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, A, B) = readLine()!!.split(\" \").map(String::toLong)\n val ans = MInt(2).pow(N) - MInt(1) - combination(N, A) - combination(N, B)\n println(ans)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a += b\n return a\n }\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a -= b\n return a\n }\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a *= b\n return a\n }\n\n operator fun div(b: MInt): MInt {\n val a = MInt(v)\n a /= b\n return a\n }\n\n operator fun plusAssign(b: MInt) {\n v += b.v\n if (v >= MOD) v -= MOD\n }\n\n operator fun minusAssign(b: MInt) {\n v -= b.v\n if (v < 0) v += MOD\n }\n\n operator fun timesAssign(b: MInt) {\n v *= b.v\n v %= MOD\n }\n\n operator fun divAssign(b: MInt) {\n this *= b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(N: Long): MInt {\n var ans = MInt(1)\n var a = this\n var n = N\n while (n > 0) {\n if (n.and(1) == 1L) {\n ans = ans * a\n }\n a = a * a\n n = n.shr(1)\n }\n return ans\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}\n\nfun combination(n: Long, k: Long): MInt {\n var a = MInt(1)\n var b = MInt(1)\n val min = Math.min(n - k, k)\n for (i in n - min + 1..n) {\n a = a * MInt(i)\n }\n for (i in 1..min) {\n b = b * MInt(i)\n }\n return a / b\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2134, "cpu_time_ms": 284, "memory_kb": 50564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s685602174", "group_id": "codeNet:p02769", "input_text": "fun main(args: Array) {\n val mod = 1000000007L\n\n val (n, k) = readInputLine().split(\" \").map { it.toInt() }\n\n val factorial = LongArray(n + 1)\n val inverse = LongArray(n + 1)\n val factorialInverse = LongArray(n + 1)\n factorial[0] = 1L\n factorial[1] = 1L\n inverse[0] = 1L\n inverse[1] = 1L\n factorialInverse[0] = 1L\n factorialInverse[1] = 1L\n for (i in 2..n) {\n factorial[i] = (factorial[i - 1] * i.toLong() % mod)\n inverse[i] = (mod - inverse[mod.toInt() % i] * (mod / i.toLong()) % mod)\n factorialInverse[i] = (factorialInverse[i - 1] * inverse[i] % mod)\n }\n\n fun nCm(n: Int, m: Int): Long {\n return factorial[n] * (factorialInverse[m] * factorialInverse[n - m] % mod) % mod\n }\n\n fun nHm(n: Int, m: Int): Long {\n return nCm(n + m - 1, m)\n }\n\n var ans = 0L\n\n for (i in 0..Math.min(n - 1, k)) {\n ans += nCm(n, i) * nHm(n - i, i) % mod\n ans %= mod\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1582416970, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02769.html", "problem_id": "p02769", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02769/input.txt", "sample_output_relpath": "derived/input_output/data/p02769/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02769/Kotlin/s685602174.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s685602174", "user_id": "u505558493"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val mod = 1000000007L\n\n val (n, k) = readInputLine().split(\" \").map { it.toInt() }\n\n val factorial = LongArray(n + 1)\n val inverse = LongArray(n + 1)\n val factorialInverse = LongArray(n + 1)\n factorial[0] = 1L\n factorial[1] = 1L\n inverse[0] = 1L\n inverse[1] = 1L\n factorialInverse[0] = 1L\n factorialInverse[1] = 1L\n for (i in 2..n) {\n factorial[i] = (factorial[i - 1] * i.toLong() % mod)\n inverse[i] = (mod - inverse[mod.toInt() % i] * (mod / i.toLong()) % mod)\n factorialInverse[i] = (factorialInverse[i - 1] * inverse[i] % mod)\n }\n\n fun nCm(n: Int, m: Int): Long {\n return factorial[n] * (factorialInverse[m] * factorialInverse[n - m] % mod) % mod\n }\n\n fun nHm(n: Int, m: Int): Long {\n return nCm(n + m - 1, m)\n }\n\n var ans = 0L\n\n for (i in 0..Math.min(n - 1, k)) {\n ans += nCm(n, i) * nHm(n - i, i) % mod\n ans %= mod\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02769", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1042, "cpu_time_ms": 282, "memory_kb": 40552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s259206670", "group_id": "codeNet:p02771", "input_text": "fun main(args: Array) {\n val list = readLine()!!.split(\" \").map(String::toInt)\n val a = list[0]\n val b = list[1]\n val c = list[2]\n if(a != b && a !=c && b != c) {\n println(\"No\")\n } else if(a == b || b == c || a == c) {\n println(\"Yes\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1582065837, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Kotlin/s259206670.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s259206670", "user_id": "u979282295"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val list = readLine()!!.split(\" \").map(String::toInt)\n val a = list[0]\n val b = list[1]\n val c = list[2]\n if(a != b && a !=c && b != c) {\n println(\"No\")\n } else if(a == b || b == c || a == c) {\n println(\"Yes\")\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 240, "memory_kb": 35984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s106368467", "group_id": "codeNet:p02771", "input_text": "fun main(args: Array) {\n val a:Int =1\n val b:Int =1\n val c:Int =1\n\n if ((b == c) && (a == b) && (c == a) && (b == a)) {\n print(\"No\")\n } else {\n print(\"Yes\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1581889146, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Kotlin/s106368467.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s106368467", "user_id": "u319722345"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val a:Int =1\n val b:Int =1\n val c:Int =1\n\n if ((b == c) && (a == b) && (c == a) && (b == a)) {\n print(\"No\")\n } else {\n print(\"Yes\")\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 177, "memory_kb": 29484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s965240300", "group_id": "codeNet:p02771", "input_text": "fun main(args: Array) {\n val list = readLine()!!.split(' ').map(String::toLong).sorted()\n\n if ((list[0] == list[1] && list[0] != list[2]) || (list[2] == list[1] && list[0] != list[2])) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1581883300, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Kotlin/s965240300.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s965240300", "user_id": "u099066216"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val list = readLine()!!.split(' ').map(String::toLong).sorted()\n\n if ((list[0] == list[1] && list[0] != list[2]) || (list[2] == list[1] && list[0] != list[2])) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 267, "cpu_time_ms": 238, "memory_kb": 36340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s704370455", "group_id": "codeNet:p02772", "input_text": "fun main(args: Array) {\n // Your code here!\n var n = readLine()!!.toInt()\n var numList = readLine()!!.split(\" \").map{it.toInt()}\n numList.forEach {\n if (it % 2 == 0 && it % 3 != 0 && it % 5 != 0) {\n println(\"DENIED\")\n return\n }\n }\n println(\"APPROVED\") \n}", "language": "Kotlin", "metadata": {"date": 1586455477, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02772/input.txt", "sample_output_relpath": "derived/input_output/data/p02772/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02772/Kotlin/s704370455.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s704370455", "user_id": "u808976884"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "fun main(args: Array) {\n // Your code here!\n var n = readLine()!!.toInt()\n var numList = readLine()!!.split(\" \").map{it.toInt()}\n numList.forEach {\n if (it % 2 == 0 && it % 3 != 0 && it % 5 != 0) {\n println(\"DENIED\")\n return\n }\n }\n println(\"APPROVED\") \n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "sample_input": "5\n6 7 9 10 31\n"}, "reference_outputs": ["APPROVED\n"], "source_document_id": "p02772", "source_text": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 316, "cpu_time_ms": 233, "memory_kb": 35944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s470698118", "group_id": "codeNet:p02772", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { \n sc.nextInt()\n }\n\n abc155b(a)\n}\n\nfun abc155b(a: List) {\n var ans = \"APPROVED\"\n\n var ok = false\n a.filter { it % 2 == 0 }.forEach { \n if (it % 3 != 0 && it % 5 != 0) {\n ok = true\n }\n }\n if (ok) {\n ans = \"DENIED\"\n }\n\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1581884123, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02772/input.txt", "sample_output_relpath": "derived/input_output/data/p02772/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02772/Kotlin/s470698118.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470698118", "user_id": "u323522006"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { \n sc.nextInt()\n }\n\n abc155b(a)\n}\n\nfun abc155b(a: List) {\n var ans = \"APPROVED\"\n\n var ok = false\n a.filter { it % 2 == 0 }.forEach { \n if (it % 3 != 0 && it % 5 != 0) {\n ok = true\n }\n }\n if (ok) {\n ans = \"DENIED\"\n }\n\n\n println(ans)\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "sample_input": "5\n6 7 9 10 31\n"}, "reference_outputs": ["APPROVED\n"], "source_document_id": "p02772", "source_text": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 200, "memory_kb": 31524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s902065271", "group_id": "codeNet:p02773", "input_text": "fun main(array: Array) {\n val n = readLine()!!.toInt()\n val list = mutableMapOf()\n var max = 1\n repeat(n) {\n val s = readLine()!!\n if(list.containsKey(s)) {\n list[s] = list[s]!!.plus(1)\n if(max < list[s]!!) max = list[s]!!\n }\n else {\n list += s to 1\n }\n }\n list.filter { it.value == max }.toSortedMap().forEach{ println(it.key)}\n}", "language": "Kotlin", "metadata": {"date": 1590764277, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Kotlin/s902065271.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s902065271", "user_id": "u124119858"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "fun main(array: Array) {\n val n = readLine()!!.toInt()\n val list = mutableMapOf()\n var max = 1\n repeat(n) {\n val s = readLine()!!\n if(list.containsKey(s)) {\n list[s] = list[s]!!.plus(1)\n if(max < list[s]!!) max = list[s]!!\n }\n else {\n list += s to 1\n }\n }\n list.filter { it.value == max }.toSortedMap().forEach{ println(it.key)}\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 437, "cpu_time_ms": 1845, "memory_kb": 103224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s032749896", "group_id": "codeNet:p02773", "input_text": "import kotlin.comparisons.compareBy\nimport kotlin.comparisons.thenBy\n\nfun main(args: Array) {\n\n val map = mutableMapOf()\n var max = 0\n repeat(readLine()!!.toInt()) {\n readLine()!!.let {\n val value = map.getOrElse(it, { 0 }) + 1\n map.put(it, value)\n max = Math.max(value, max)\n\n }\n }\n\n map.toList().filter { it.second == max }\n .sortedWith(compareBy> { it.second }.thenBy { it.first })\n .forEach {\n println(it.first)\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1589579777, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Kotlin/s032749896.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s032749896", "user_id": "u085288971"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "import kotlin.comparisons.compareBy\nimport kotlin.comparisons.thenBy\n\nfun main(args: Array) {\n\n val map = mutableMapOf()\n var max = 0\n repeat(readLine()!!.toInt()) {\n readLine()!!.let {\n val value = map.getOrElse(it, { 0 }) + 1\n map.put(it, value)\n max = Math.max(value, max)\n\n }\n }\n\n map.toList().filter { it.second == max }\n .sortedWith(compareBy> { it.second }.thenBy { it.first })\n .forEach {\n println(it.first)\n }\n}\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 555, "cpu_time_ms": 1885, "memory_kb": 95780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s327700538", "group_id": "codeNet:p02773", "input_text": "import kotlin.comparisons.compareByDescending\nimport kotlin.comparisons.thenBy\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val count = mutableMapOf()\n repeat(n) {\n val s = readLine()!!\n val c = count.getOrPut(s, { 0 }) + 1\n count[s] = c\n }\n val ans = count.toList().sortedWith(compareByDescending> { it.second }.thenBy { it.first })\n for (x in ans) {\n if (x.second != ans[0].second) {\n break\n }\n println(x.first)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1583231066, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Kotlin/s327700538.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s327700538", "user_id": "u733811860"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "import kotlin.comparisons.compareByDescending\nimport kotlin.comparisons.thenBy\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val count = mutableMapOf()\n repeat(n) {\n val s = readLine()!!\n val c = count.getOrPut(s, { 0 }) + 1\n count[s] = c\n }\n val ans = count.toList().sortedWith(compareByDescending> { it.second }.thenBy { it.first })\n for (x in ans) {\n if (x.second != ans[0].second) {\n break\n }\n println(x.first)\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 543, "cpu_time_ms": 2028, "memory_kb": 96016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s076119801", "group_id": "codeNet:p02773", "input_text": "import java.util.*\n\nfun main(args : Array) {\n val n = readLine()!!.toInt()\n val ss = mutableMapOf()\n var max = 0\n var ans = ArrayList()\n\n repeat(n) {\n val s = readLine()!!\n ss[s] = (ss[s] ?: 0) + 1\n if (ss[s]!! == max) {\n ans.add(s)\n }\n if (ss[s]!! > max) {\n max = ss[s]!!\n ans = ArrayList()\n ans.add(s)\n }\n }\n\n ans.sorted().forEach {\n println(it)\n }\n}", "language": "Kotlin", "metadata": {"date": 1581884909, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Kotlin/s076119801.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s076119801", "user_id": "u262403099"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n val n = readLine()!!.toInt()\n val ss = mutableMapOf()\n var max = 0\n var ans = ArrayList()\n\n repeat(n) {\n val s = readLine()!!\n ss[s] = (ss[s] ?: 0) + 1\n if (ss[s]!! == max) {\n ans.add(s)\n }\n if (ss[s]!! > max) {\n max = ss[s]!!\n ans = ArrayList()\n ans.add(s)\n }\n }\n\n ans.sorted().forEach {\n println(it)\n }\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 498, "cpu_time_ms": 2107, "memory_kb": 92488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s854390468", "group_id": "codeNet:p02777", "input_text": "fun main(args:Array){\n val a=readLine()!!.split( \" \")\n val b=readLine()!!.split( \" \").map{it.toInt()}\n val c=readLine()!!\n if (a[0]==c){\n when {\n b[0]-1>=1 && b[1]>=1 ->{ println(\"${b[0]} ${b[1]}\")}\n b[0]-1>=1 && b[1]==0 ->{ println(\"${b[0]}\")}\n b[0]-1==0 && b[1]>=1 ->{ println(\"${b[1]}\")}\n }\n }else if (a[1]==c){\n when {\n b[0] >= 1 && b[1] - 1 >= 1 -> {\n println(\"${b[0]} ${b[1]}\")\n }\n b[0] >= 1 && b[1] - 1 == 0 -> {\n println(\"${b[0]}\")\n }\n b[0] == 0 && b[1] - 1 >= 1 -> {\n println(\"${b[1]}\")\n }\n }\n }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1586602692, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/Kotlin/s854390468.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s854390468", "user_id": "u387080888"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "fun main(args:Array){\n val a=readLine()!!.split( \" \")\n val b=readLine()!!.split( \" \").map{it.toInt()}\n val c=readLine()!!\n if (a[0]==c){\n when {\n b[0]-1>=1 && b[1]>=1 ->{ println(\"${b[0]} ${b[1]}\")}\n b[0]-1>=1 && b[1]==0 ->{ println(\"${b[0]}\")}\n b[0]-1==0 && b[1]>=1 ->{ println(\"${b[1]}\")}\n }\n }else if (a[1]==c){\n when {\n b[0] >= 1 && b[1] - 1 >= 1 -> {\n println(\"${b[0]} ${b[1]}\")\n }\n b[0] >= 1 && b[1] - 1 == 0 -> {\n println(\"${b[0]}\")\n }\n b[0] == 0 && b[1] - 1 >= 1 -> {\n println(\"${b[1]}\")\n }\n }\n }\n}\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 705, "cpu_time_ms": 240, "memory_kb": 37832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s276597450", "group_id": "codeNet:p02777", "input_text": "fun main(args: Array) {\n val color = readLine()!!.split(\" \").map(String::toString)\n val size = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n val select = readLine()!!.toString()\n\n if (select == color[0]) size[0] = size[0] -1 else size[1] = size[1] -1\n println(\"${size[0]} ${size[1]}\")\n}", "language": "Kotlin", "metadata": {"date": 1581279509, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/Kotlin/s276597450.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s276597450", "user_id": "u039906164"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "fun main(args: Array) {\n val color = readLine()!!.split(\" \").map(String::toString)\n val size = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n val select = readLine()!!.toString()\n\n if (select == color[0]) size[0] = size[0] -1 else size[1] = size[1] -1\n println(\"${size[0]} ${size[1]}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 323, "cpu_time_ms": 237, "memory_kb": 37884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s011047822", "group_id": "codeNet:p02777", "input_text": "fun main(args: Array){\n\n val (S, T) = readLine()!!.split(\" \")\n val (A, B) = readLine()!!.split(\" \").map { it.toInt() }\n val U = readLine()!!\n\n if(S==U) println(\"${A-1} $B\") else println(\"$A ${B-1}\")\n}", "language": "Kotlin", "metadata": {"date": 1581278672, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/Kotlin/s011047822.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011047822", "user_id": "u108272327"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "fun main(args: Array){\n\n val (S, T) = readLine()!!.split(\" \")\n val (A, B) = readLine()!!.split(\" \").map { it.toInt() }\n val U = readLine()!!\n\n if(S==U) println(\"${A-1} $B\") else println(\"$A ${B-1}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 220, "cpu_time_ms": 242, "memory_kb": 36104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s023494072", "group_id": "codeNet:p02777", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (s, t) = readListOfString()\n\tvar (a, b) = readListOfInt()\n\tval u = read()\n\n\tif(u == s) {\n\t\ta--\n\t} else {\n\t\tb--\n\t}\n\n\tprintln(\"$a $b\")\n\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// return nCr % MOD\nfun modCombinations(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1581278512, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/Kotlin/s023494072.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023494072", "user_id": "u026686258"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval (s, t) = readListOfString()\n\tvar (a, b) = readListOfInt()\n\tval u = read()\n\n\tif(u == s) {\n\t\ta--\n\t} else {\n\t\tb--\n\t}\n\n\tprintln(\"$a $b\")\n\n\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// return nCr % MOD\nfun modCombinations(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4458, "cpu_time_ms": 246, "memory_kb": 36168}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s826043978", "group_id": "codeNet:p02778", "input_text": "fun main(){\n val S = readLine()!!.split(\"\").filter { it != \"\" }\n println(\"x\".repeat(S.size))\n}", "language": "Kotlin", "metadata": {"date": 1597123619, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02778.html", "problem_id": "p02778", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02778/input.txt", "sample_output_relpath": "derived/input_output/data/p02778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02778/Kotlin/s826043978.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826043978", "user_id": "u035856025"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "fun main(){\n val S = readLine()!!.split(\"\").filter { it != \"\" }\n println(\"x\".repeat(S.size))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a string S. Replace every character in S with x and print the result.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace every character in S with x and print the result.\n\nSample Input 1\n\nsardine\n\nSample Output 1\n\nxxxxxxx\n\nReplacing every character in S with x results in xxxxxxx.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\nxxxx\n\nSample Input 3\n\ngone\n\nSample Output 3\n\nxxxx", "sample_input": "sardine\n"}, "reference_outputs": ["xxxxxxx\n"], "source_document_id": "p02778", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a string S. Replace every character in S with x and print the result.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace every character in S with x and print the result.\n\nSample Input 1\n\nsardine\n\nSample Output 1\n\nxxxxxxx\n\nReplacing every character in S with x results in xxxxxxx.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\nxxxx\n\nSample Input 3\n\ngone\n\nSample Output 3\n\nxxxx", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 100, "cpu_time_ms": 139, "memory_kb": 39724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s908018035", "group_id": "codeNet:p02779", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map {\n sc.next().toLong()\n }\n\n abc154c(a)\n}\n\nfun abc154c(a: List) {\n var ans = \"YES\"\n for (i in 0..a.size - 1) {\n var ai = a.get(i)\n if (i != a.indexOf(ai)) {\n ans = \"NO\" \n break\n }\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1581279651, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/Kotlin/s908018035.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s908018035", "user_id": "u323522006"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map {\n sc.next().toLong()\n }\n\n abc154c(a)\n}\n\nfun abc154c(a: List) {\n var ans = \"YES\"\n for (i in 0..a.size - 1) {\n var ai = a.get(i)\n if (i != a.indexOf(ai)) {\n ans = \"NO\" \n break\n }\n }\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 408, "cpu_time_ms": 2111, "memory_kb": 58112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s663223441", "group_id": "codeNet:p02780", "input_text": " fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val p = readLine()!!.split(\" \").map { it.toInt() }\n\n\n fun getExv(max: Int): Double {\n var sum = 0\n for (i in 1..max) {\n sum += i\n }\n return (sum.toDouble() / max.toDouble())\n }\n\n fun getSumExv(position: Int, k: Int, exvList: List): Double {\n var result = 0.0\n var max = position + k\n for (i in position until max) {\n result += exvList[i]\n }\n println(\"$result\")\n return result\n }\n\n // 5 3\n // 1 2 2 4 5\n\n val exvList = mutableListOf()\n\n p.forEach {\n exvList.add(getExv(it))\n }\n println(\"$exvList\")\n\n var sum = 0.0\n var maxPosition = 0\n exvList.forEachIndexed { index, l ->\n if (n < index + k) {\n return\n }\n\n val sumExv = getSumExv(index, k, exvList)\n if (sum < sumExv) {\n maxPosition = index\n sum = sumExv\n }\n }\n\n println(\"$sum\")\n println(\"$maxPosition\")\n }", "language": "Kotlin", "metadata": {"date": 1581284961, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02780/input.txt", "sample_output_relpath": "derived/input_output/data/p02780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02780/Kotlin/s663223441.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s663223441", "user_id": "u366280250"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": " fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val p = readLine()!!.split(\" \").map { it.toInt() }\n\n\n fun getExv(max: Int): Double {\n var sum = 0\n for (i in 1..max) {\n sum += i\n }\n return (sum.toDouble() / max.toDouble())\n }\n\n fun getSumExv(position: Int, k: Int, exvList: List): Double {\n var result = 0.0\n var max = position + k\n for (i in position until max) {\n result += exvList[i]\n }\n println(\"$result\")\n return result\n }\n\n // 5 3\n // 1 2 2 4 5\n\n val exvList = mutableListOf()\n\n p.forEach {\n exvList.add(getExv(it))\n }\n println(\"$exvList\")\n\n var sum = 0.0\n var maxPosition = 0\n exvList.forEachIndexed { index, l ->\n if (n < index + k) {\n return\n }\n\n val sumExv = getSumExv(index, k, exvList)\n if (sum < sumExv) {\n maxPosition = index\n sum = sumExv\n }\n }\n\n println(\"$sum\")\n println(\"$maxPosition\")\n }", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "sample_input": "5 3\n1 2 2 4 5\n"}, "reference_outputs": ["7.000000000000\n"], "source_document_id": "p02780", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1246, "cpu_time_ms": 2111, "memory_kb": 102228}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s062851192", "group_id": "codeNet:p02782", "input_text": "fun main(args: Array) {\n val (r1, c1, r2, c2) = readLine()!!.split(\" \").map(String::toInt)\n val combi = Combination(2000002)\n val ans = combi(r2 + c2 + 2, c2 + 1) - combi(r2 + c1 + 1, c1) - combi(r1 + c2 + 1, c2 + 1) + combi(r1 + c1, c1)\n println(ans)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a += b\n return a\n }\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a -= b\n return a\n }\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a *= b\n return a\n }\n\n operator fun div(b: MInt): MInt {\n val a = MInt(v)\n a /= b\n return a\n }\n\n operator fun plusAssign(b: MInt) {\n v += b.v\n if (v >= MOD) v -= MOD\n }\n\n operator fun minusAssign(b: MInt) {\n v -= b.v\n if (v < 0) v += MOD\n }\n\n operator fun timesAssign(b: MInt) {\n v *= b.v\n v %= MOD\n }\n\n operator fun divAssign(b: MInt) {\n this *= b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(n: Int): MInt {\n var a = MInt(1)\n for (i in 1..n) a = a * this\n return a\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}\n\nclass Combination(n: Int) {\n private val fact = arrayOfNulls(n + 1)\n private val ifact = arrayOfNulls(n + 1)\n\n init {\n fact[0] = MInt(1)\n (1..n).forEach { i -> fact[i] = fact[i - 1]!! * MInt(i) }\n ifact[n] = fact[n]!!.inv()\n (n downTo 1).forEach { i -> ifact[i - 1] = ifact[i]!! * MInt(i) }\n }\n\n operator fun invoke(n: Int, k: Int): MInt {\n if (k < 0 || n < k) return MInt(0)\n return (fact[n]!! * ifact[k]!! * ifact[n - k]!!)\n }\n}", "language": "Kotlin", "metadata": {"date": 1581295158, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02782.html", "problem_id": "p02782", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02782/input.txt", "sample_output_relpath": "derived/input_output/data/p02782/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02782/Kotlin/s062851192.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s062851192", "user_id": "u860789370"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main(args: Array) {\n val (r1, c1, r2, c2) = readLine()!!.split(\" \").map(String::toInt)\n val combi = Combination(2000002)\n val ans = combi(r2 + c2 + 2, c2 + 1) - combi(r2 + c1 + 1, c1) - combi(r1 + c2 + 1, c2 + 1) + combi(r1 + c1, c1)\n println(ans)\n}\n\nclass MInt {\n private val MOD = 1000000007L\n var v: Long\n\n constructor(v: Long) {\n this.v = v % MOD\n }\n\n constructor(v: Int) {\n this.v = v.toLong() % MOD\n }\n\n operator fun plus(b: MInt): MInt {\n val a = MInt(v)\n a += b\n return a\n }\n\n operator fun minus(b: MInt): MInt {\n val a = MInt(v)\n a -= b\n return a\n }\n\n operator fun times(b: MInt): MInt {\n val a = MInt(v)\n a *= b\n return a\n }\n\n operator fun div(b: MInt): MInt {\n val a = MInt(v)\n a /= b\n return a\n }\n\n operator fun plusAssign(b: MInt) {\n v += b.v\n if (v >= MOD) v -= MOD\n }\n\n operator fun minusAssign(b: MInt) {\n v -= b.v\n if (v < 0) v += MOD\n }\n\n operator fun timesAssign(b: MInt) {\n v *= b.v\n v %= MOD\n }\n\n operator fun divAssign(b: MInt) {\n this *= b.inv()\n }\n\n fun inv(): MInt {\n var a = v\n var b = MOD\n var u = 1L\n var w = 0L\n while (b != 0L) {\n val t = a / b\n a -= t * b\n u -= t * w\n var tmp = a\n a = b\n b = tmp\n tmp = u\n u = w\n w = tmp\n }\n u %= MOD\n if (u < 0) u += MOD\n return MInt(u)\n }\n\n fun pow(n: Int): MInt {\n var a = MInt(1)\n for (i in 1..n) a = a * this\n return a\n }\n\n override fun toString(): String {\n return v.toString()\n }\n}\n\nclass Combination(n: Int) {\n private val fact = arrayOfNulls(n + 1)\n private val ifact = arrayOfNulls(n + 1)\n\n init {\n fact[0] = MInt(1)\n (1..n).forEach { i -> fact[i] = fact[i - 1]!! * MInt(i) }\n ifact[n] = fact[n]!!.inv()\n (n downTo 1).forEach { i -> ifact[i - 1] = ifact[i]!! * MInt(i) }\n }\n\n operator fun invoke(n: Int, k: Int): MInt {\n if (k < 0 || n < k) return MInt(0)\n return (fact[n]!! * ifact[k]!! * ifact[n - k]!!)\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\n\nLet us define a function f(r, c) as follows:\n\nf(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)\n\nGiven are integers r_1, r_2, c_1, and c_2.\nFind the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).\n\nConstraints\n\n1 ≤ r_1 ≤ r_2 ≤ 10^6\n\n1 ≤ c_1 ≤ c_2 ≤ 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr_1 c_1 r_2 c_2\n\nOutput\n\nPrint the sum of f(i, j) modulo (10^9+7).\n\nSample Input 1\n\n1 1 2 2\n\nSample Output 1\n\n14\n\nFor example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.\n\nSimilarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.\n\nSample Input 2\n\n314 159 2653 589\n\nSample Output 2\n\n602215194", "sample_input": "1 1 2 2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02782", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\n\nLet us define a function f(r, c) as follows:\n\nf(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)\n\nGiven are integers r_1, r_2, c_1, and c_2.\nFind the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).\n\nConstraints\n\n1 ≤ r_1 ≤ r_2 ≤ 10^6\n\n1 ≤ c_1 ≤ c_2 ≤ 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr_1 c_1 r_2 c_2\n\nOutput\n\nPrint the sum of f(i, j) modulo (10^9+7).\n\nSample Input 1\n\n1 1 2 2\n\nSample Output 1\n\n14\n\nFor example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.\n\nSimilarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.\n\nSample Input 2\n\n314 159 2653 589\n\nSample Output 2\n\n602215194", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2301, "cpu_time_ms": 1838, "memory_kb": 287712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s924214377", "group_id": "codeNet:p02783", "input_text": "fun main(args: Array) {\n val (H, A) = readIntList()\n println(H/A+1)\n}\n\nfun readString() = readLine()!!\nfun readStringList() = readLine()!!.split(\" \")\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1581699367, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02783/input.txt", "sample_output_relpath": "derived/input_output/data/p02783/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02783/Kotlin/s924214377.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s924214377", "user_id": "u043557308"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, A) = readIntList()\n println(H/A+1)\n}\n\nfun readString() = readLine()!!\nfun readStringList() = readLine()!!.split(\" \")\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "sample_input": "10 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02783", "source_text": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 367, "cpu_time_ms": 243, "memory_kb": 37608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s670878148", "group_id": "codeNet:p02783", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (H, A) = readLine()!!.split(\" \").map { it.toInt() }\n \n if (H%A == 0)\n println(\"${H/A}\")\n else\n println(\"${H/A+1}\")\n}", "language": "Kotlin", "metadata": {"date": 1580070072, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02783/input.txt", "sample_output_relpath": "derived/input_output/data/p02783/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02783/Kotlin/s670878148.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s670878148", "user_id": "u396720407"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (H, A) = readLine()!!.split(\" \").map { it.toInt() }\n \n if (H%A == 0)\n println(\"${H/A}\")\n else\n println(\"${H/A+1}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "sample_input": "10 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02783", "source_text": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 245, "memory_kb": 36080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s836790632", "group_id": "codeNet:p02784", "input_text": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val YES = \"Yes\"\nconst val NO = \"No\"\nfun solve(H: Long, N: Long, A: LongArray){\n if (A.sum() >= H) println(YES) else println(NO)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val H = sc.next().toLong()\n val N = sc.next().toLong()\n val A = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n A[i] = sc.next().toLong()\n }\n solve(H, N, A)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1580130740, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02784/input.txt", "sample_output_relpath": "derived/input_output/data/p02784/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02784/Kotlin/s836790632.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s836790632", "user_id": "u329232967"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val YES = \"Yes\"\nconst val NO = \"No\"\nfun solve(H: Long, N: Long, A: LongArray){\n if (A.sum() >= H) println(YES) else println(NO)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val H = sc.next().toLong()\n val N = sc.next().toLong()\n val A = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n A[i] = sc.next().toLong()\n }\n solve(H, N, A)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRaccoon is fighting with a monster.\n\nThe health of the monster is H.\n\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\n\nRaccoon wins when the monster's health becomes 0 or below.\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq H \\leq 10^9\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 A_2 ... A_N\n\nOutput\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n10 3\n4 5 6\n\nSample Output 1\n\nYes\n\nThe monster's health will become 0 or below after, for example, using the second and third moves.\n\nSample Input 2\n\n20 3\n4 5 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n210 5\n31 41 59 26 53\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n211 5\n31 41 59 26 53\n\nSample Output 4\n\nNo", "sample_input": "10 3\n4 5 6\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02784", "source_text": "Score : 200 points\n\nProblem Statement\n\nRaccoon is fighting with a monster.\n\nThe health of the monster is H.\n\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\n\nRaccoon wins when the monster's health becomes 0 or below.\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq H \\leq 10^9\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 A_2 ... A_N\n\nOutput\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n10 3\n4 5 6\n\nSample Output 1\n\nYes\n\nThe monster's health will become 0 or below after, for example, using the second and third moves.\n\nSample Input 2\n\n20 3\n4 5 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n210 5\n31 41 59 26 53\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n211 5\n31 41 59 26 53\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 949, "cpu_time_ms": 343, "memory_kb": 42236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s242910326", "group_id": "codeNet:p02785", "input_text": "import java.util.*\n\nfun main(args:Array){\n val (n,k) = readLine()!!.split(\" \").map{it.toInt()}\n val a = readLine()!!.split(\" \").map{it.toLong()}.sorted()\n var ans = 0L\n for(i in 0 until n - k){\n ans += a[i]\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1581252561, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02785/input.txt", "sample_output_relpath": "derived/input_output/data/p02785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02785/Kotlin/s242910326.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s242910326", "user_id": "u480831358"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val (n,k) = readLine()!!.split(\" \").map{it.toInt()}\n val a = readLine()!!.split(\" \").map{it.toLong()}.sorted()\n var ans = 0L\n for(i in 0 until n - k){\n ans += a[i]\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 1\n4 1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02785", "source_text": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 987, "memory_kb": 83640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s343192261", "group_id": "codeNet:p02786", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(H: Long){\n fun count(h: Long): Long =\n when(h){\n 1L -> 1L\n else -> 1 + 2*count(h/2)\n }\n println(count(H))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val H = sc.next().toLong()\n solve(H)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1580131077, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02786.html", "problem_id": "p02786", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02786/input.txt", "sample_output_relpath": "derived/input_output/data/p02786/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02786/Kotlin/s343192261.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343192261", "user_id": "u329232967"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(H: Long){\n fun count(h: Long): Long =\n when(h){\n 1L -> 1L\n else -> 1 + 2*count(h/2)\n }\n println(count(H))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val H = sc.next().toLong()\n solve(H)\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "sample_input": "2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02786", "source_text": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 792, "cpu_time_ms": 180, "memory_kb": 31260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s951409574", "group_id": "codeNet:p02787", "input_text": "fun main(args: Array) {\n\n val (h,n) = readLine()!!.split(\" \").map{ it.toInt() }\n\n val magicList = mutableListOf()\n\n repeat(n) {\n val (a,b) = readLine()!!.split(\" \").map{ it.toInt() }\n magicList.add(Magic(a,b))\n }\n\n\n val dp = IntArray (h+1)\n dp[0] = 0\n for (i in 1..h) {\n dp[i] = (0 until n).map{\n dp.getOrElse(i-magicList[it].atk){0} + magicList[it].mp\n }.min()!!\n }\n\n println(dp[h])\n\n}\n\nclass Magic(val atk: Int, val mp:Int)\n", "language": "Kotlin", "metadata": {"date": 1583631837, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02787.html", "problem_id": "p02787", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02787/input.txt", "sample_output_relpath": "derived/input_output/data/p02787/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02787/Kotlin/s951409574.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s951409574", "user_id": "u288435405"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (h,n) = readLine()!!.split(\" \").map{ it.toInt() }\n\n val magicList = mutableListOf()\n\n repeat(n) {\n val (a,b) = readLine()!!.split(\" \").map{ it.toInt() }\n magicList.add(Magic(a,b))\n }\n\n\n val dp = IntArray (h+1)\n dp[0] = 0\n for (i in 1..h) {\n dp[i] = (0 until n).map{\n dp.getOrElse(i-magicList[it].atk){0} + magicList[it].mp\n }.min()!!\n }\n\n println(dp[h])\n\n}\n\nclass Magic(val atk: Int, val mp:Int)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "sample_input": "9 3\n8 3\n4 2\n2 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02787", "source_text": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 586, "memory_kb": 112956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s992072268", "group_id": "codeNet:p02787", "input_text": "fun main(args:Array) {\n\n val (h,n) = readLine()!!.split(\" \").map { it.toInt() }\n val item = Array(n){0 to 0}\n\n for(i in 0 until n) {\n val (damage, point) = readLine()!!.split(\" \").map { it.toInt() }\n item[i] = damage to point\n }\n val inf = 100000000\n // 10000000\n val dp =Array(h+1){inf}\n dp[0] = 0\n for(i in 0 until n) {\n val (damage, point) = item[i]\n for(j in 1..h) {\n val diff = j - damage\n val prev = if(diff < 0) 0 else diff \n if(dp[j] > dp[prev]+point) {\n dp[j] = dp[prev]+point\n }\n }\n }\n println(dp[h])\n}", "language": "Kotlin", "metadata": {"date": 1580073369, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02787.html", "problem_id": "p02787", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02787/input.txt", "sample_output_relpath": "derived/input_output/data/p02787/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02787/Kotlin/s992072268.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s992072268", "user_id": "u682597394"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args:Array) {\n\n val (h,n) = readLine()!!.split(\" \").map { it.toInt() }\n val item = Array(n){0 to 0}\n\n for(i in 0 until n) {\n val (damage, point) = readLine()!!.split(\" \").map { it.toInt() }\n item[i] = damage to point\n }\n val inf = 100000000\n // 10000000\n val dp =Array(h+1){inf}\n dp[0] = 0\n for(i in 0 until n) {\n val (damage, point) = item[i]\n for(j in 1..h) {\n val diff = j - damage\n val prev = if(diff < 0) 0 else diff \n if(dp[j] > dp[prev]+point) {\n dp[j] = dp[prev]+point\n }\n }\n }\n println(dp[h])\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "sample_input": "9 3\n8 3\n4 2\n2 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02787", "source_text": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 647, "cpu_time_ms": 340, "memory_kb": 40752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s195088258", "group_id": "codeNet:p02788", "input_text": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val d = readInt()\n val a = readInt()\n\n val M = Array(n) {\n Monster(readInt(), readInt())\n }\n\n M.sortBy { it.x }\n\n val R = ArrayDeque()\n var dam = 0\n var ans = 0L\n\n for((x, h) in M) {\n while(R.isNotEmpty() && R.first.x < x-d) {\n dam -= R.removeFirst().d\n }\n\n if(h > dam) {\n val k = h-dam divCeil a\n ans += k\n dam += k*a\n R.add(RB(x+d, k*a))\n }\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ndata class Monster(val x: Int, val h: Int)\ndata class RB(val x: Int, val d: Int)\ninfix fun Int.divCeil(other: Int) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "language": "Kotlin", "metadata": {"date": 1593512150, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02788.html", "problem_id": "p02788", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02788/input.txt", "sample_output_relpath": "derived/input_output/data/p02788/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02788/Kotlin/s195088258.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s195088258", "user_id": "u596111103"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "@file:Suppress(\"NOTHING_TO_INLINE\", \"EXPERIMENTAL_FEATURE_WARNING\", \"OVERRIDE_BY_INLINE\")\n//@file:OptIn(ExperimentalStdlibApi::class)\n\nimport java.io.PrintWriter\nimport java.util.ArrayDeque\nimport java.util.PriorityQueue\nimport kotlin.math.*\nimport kotlin.random.Random\nimport kotlin.collections.sort as _sort\nimport kotlin.collections.sortDescending as _sortDescending\nimport kotlin.io.println as iprintln\n\n/** @author Spheniscine */\nfun main() { _writer.solve(); _writer.flush() }\n\nfun PrintWriter.solve() {\n// val startTime = System.nanoTime()\n\n val numCases = 1//readInt()\n case@ for(case in 1..numCases) {\n //print(\"Case #$case: \")\n\n val n = readInt()\n val d = readInt()\n val a = readInt()\n\n val M = Array(n) {\n Monster(readInt(), readInt())\n }\n\n M.sortBy { it.x }\n\n val R = ArrayDeque()\n var dam = 0\n var ans = 0L\n\n for((x, h) in M) {\n while(R.isNotEmpty() && R.first.x < x-d) {\n dam -= R.removeFirst().d\n }\n\n if(h > dam) {\n val k = h-dam divCeil a\n ans += k\n dam += k*a\n R.add(RB(x+d, k*a))\n }\n }\n\n println(ans)\n }\n\n// iprintln(\"Time: ${(System.nanoTime() - startTime) / 1000000} ms\")\n}\n\ndata class Monster(val x: Int, val h: Int)\ndata class RB(val x: Int, val d: Int)\ninfix fun Int.divCeil(other: Int) =\n (this / other).let { if(xor(other) >= 0 && it * other != this) it+1 else it }\n\n/** IO */\n//@JvmField val INPUT = File(\"input.txt\").inputStream()\n//@JvmField val OUTPUT = File(\"output.txt\").outputStream()\n@JvmField val INPUT = System.`in`\n@JvmField val OUTPUT = System.out\n\nconst val _BUFFER_SIZE = 1 shl 16\n@JvmField val _buffer = ByteArray(_BUFFER_SIZE)\n@JvmField var _bufferPt = 0\n@JvmField var _bytesRead = 0\n\ntailrec fun readChar(): Char {\n if(_bufferPt == _bytesRead) {\n _bufferPt = 0\n _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)\n }\n return if(_bytesRead < 0) Char.MIN_VALUE\n else {\n val c = _buffer[_bufferPt++].toChar()\n if (c == '\\r') readChar()\n else c\n }\n}\n\nfun readLine(): String? {\n var c = readChar()\n return if(c == Char.MIN_VALUE) null\n else buildString {\n while(c != '\\n' && c != Char.MIN_VALUE) {\n append(c)\n c = readChar()\n }\n }\n}\nfun readLn() = readLine()!!\n\nfun read() = buildString {\n var c = readChar()\n while(c <= ' ') {\n if(c == Char.MIN_VALUE) return@buildString\n c = readChar()\n }\n do {\n append(c)\n c = readChar()\n } while(c > ' ')\n}\nfun readInt() = read().toInt()\nfun readDouble() = read().toDouble()\nfun readLong() = read().toLong()\nfun readStrings(n: Int) = List(n) { read() }\nfun readLines(n: Int) = List(n) { readLn() }\nfun readInts(n: Int) = List(n) { read().toInt() }\nfun readIntArray(n: Int) = IntArray(n) { read().toInt() }\nfun readDoubles(n: Int) = List(n) { read().toDouble() }\nfun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }\nfun readLongs(n: Int) = List(n) { read().toLong() }\nfun readLongArray(n: Int) = LongArray(n) { read().toLong() }\n\n@JvmField val _writer = PrintWriter(OUTPUT, false)\n\n/** shuffles and sort overrides to avoid quicksort attacks */\nprivate inline fun _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {\n // Fisher-Yates shuffle algorithm\n for (i in size - 1 downTo 1) {\n val j = rnd.nextInt(i + 1)\n val temp = get(i)\n set(i, get(j))\n set(j, temp)\n }\n}\n\n@JvmField var _random: Random? = null\nval random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }\n\nfun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun IntArray.sort() { shuffle(); _sort() }\nfun IntArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun LongArray.sort() { shuffle(); _sort() }\nfun LongArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\nfun DoubleArray.sort() { shuffle(); _sort() }\nfun DoubleArray.sortDescending() { shuffle(); _sortDescending() }\n\nfun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)\ninline fun CharArray.sort() { _sort() }\ninline fun CharArray.sortDescending() { _sortDescending() }\n\ninline fun > Array.sort() = _sort()\ninline fun > Array.sortDescending() = _sortDescending()\ninline fun > MutableList.sort() = _sort()\ninline fun > MutableList.sortDescending() = _sortDescending()\n\nfun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }\n\n/** additional commons */\ninline fun Iterable.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Sequence.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\ninline fun Array.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }\nfun IntArray.sumLong() = fold(0L, Long::plus)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSilver Fox is fighting with N monsters.\n\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\n\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.\nThere is no way other than bombs to decrease the monster's health.\n\nSilver Fox wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of bombs needed to win.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq D \\leq 10^9\n\n1 \\leq A \\leq 10^9\n\n0 \\leq X_i \\leq 10^9\n\n1 \\leq H_i \\leq 10^9\n\nX_i are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D A\nX_1 H_1\n:\nX_N H_N\n\nOutput\n\nPrint the minimum number of bombs needed to win.\n\nSample Input 1\n\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1\n\n2\n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.\n\nNow, all the monsters' healths are 0.\nWe cannot make all the monsters' health drop to 0 or below with just one bomb.\n\nSample Input 2\n\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2\n\n5\n\nWe should use five bombs at the coordinate 5.\n\nSample Input 3\n\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 3 2\n1 2\n5 4\n9 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02788", "source_text": "Score : 600 points\n\nProblem Statement\n\nSilver Fox is fighting with N monsters.\n\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\n\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.\nThere is no way other than bombs to decrease the monster's health.\n\nSilver Fox wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of bombs needed to win.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq D \\leq 10^9\n\n1 \\leq A \\leq 10^9\n\n0 \\leq X_i \\leq 10^9\n\n1 \\leq H_i \\leq 10^9\n\nX_i are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D A\nX_1 H_1\n:\nX_N H_N\n\nOutput\n\nPrint the minimum number of bombs needed to win.\n\nSample Input 1\n\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1\n\n2\n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.\n\nNow, all the monsters' healths are 0.\nWe cannot make all the monsters' health drop to 0 or below with just one bomb.\n\nSample Input 2\n\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2\n\n5\n\nWe should use five bombs at the coordinate 5.\n\nSample Input 3\n\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5206, "cpu_time_ms": 547, "memory_kb": 65296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s846549135", "group_id": "codeNet:p02789", "input_text": "fun solve(N:Int, M:Int) {\n if (N == M) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n\nfun main() {\n// val S = readLine()!!\n// val N = readLine()!!.toInt()\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(N, M)\n}", "language": "Kotlin", "metadata": {"date": 1598833346, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02789/input.txt", "sample_output_relpath": "derived/input_output/data/p02789/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02789/Kotlin/s846549135.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s846549135", "user_id": "u945228737"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun solve(N:Int, M:Int) {\n if (N == M) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n\nfun main() {\n// val S = readLine()!!\n// val N = readLine()!!.toInt()\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(N, M)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 320, "cpu_time_ms": 113, "memory_kb": 36276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s422919026", "group_id": "codeNet:p02789", "input_text": "fun main(args: Array) = println(run {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n if (n == m) \"Yes\" else \"No\"\n})", "language": "Kotlin", "metadata": {"date": 1588428118, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02789/input.txt", "sample_output_relpath": "derived/input_output/data/p02789/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02789/Kotlin/s422919026.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s422919026", "user_id": "u563556491"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n if (n == m) \"Yes\" else \"No\"\n})", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 234, "memory_kb": 37928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s107563866", "group_id": "codeNet:p02789", "input_text": "fun main(args: Array) {\n var (n,m)= readLine()!!.split(\" \")\n if(n==m){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1581724234, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02789/input.txt", "sample_output_relpath": "derived/input_output/data/p02789/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02789/Kotlin/s107563866.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s107563866", "user_id": "u456173040"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n var (n,m)= readLine()!!.split(\" \")\n if(n==m){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 242, "memory_kb": 37748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s221209963", "group_id": "codeNet:p02790", "input_text": "import java.util.*\n\nfun main(args:Array){\n val (n,m) = readLine()!!.split(\" \").map{it.toInt()}\n if(n >= m){\n repeat(n){\n print(m)\n }\n println()\n }\n else{\n repeat(m){\n print(n)\n }\n println()\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1579463570, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02790.html", "problem_id": "p02790", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02790/input.txt", "sample_output_relpath": "derived/input_output/data/p02790/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02790/Kotlin/s221209963.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221209963", "user_id": "u480831358"}, "prompt_components": {"gold_output": "3333\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val (n,m) = readLine()!!.split(\" \").map{it.toInt()}\n if(n >= m){\n repeat(n){\n print(m)\n }\n println()\n }\n else{\n repeat(m){\n print(n)\n }\n println()\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "sample_input": "4 3\n"}, "reference_outputs": ["3333\n"], "source_document_id": "p02790", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 233, "memory_kb": 37624}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s548013876", "group_id": "codeNet:p02791", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = Integer.parseInt(sc.next());\n var m = n\n var a = 0\n for (i in 0..n-1) {\n val c = Integer.parseInt(sc.next());\n m = Math.min(m, c)\n if (m >= c) {\n a += 1\n }\n }\n println(a)\n}", "language": "Kotlin", "metadata": {"date": 1579513111, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Kotlin/s548013876.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548013876", "user_id": "u809192419"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = Integer.parseInt(sc.next());\n var m = n\n var a = 0\n for (i in 0..n-1) {\n val c = Integer.parseInt(sc.next());\n m = Math.min(m, c)\n if (m >= c) {\n a += 1\n }\n }\n println(a)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 633, "memory_kb": 51384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s057192083", "group_id": "codeNet:p02793", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val a = nextLongAry(n)\n val res = erathos(1000000)\n val map = map()\n for (i in a.indices) {\n val tmpmap = map()\n var now = a[i]\n while (res[now] != -1L) {\n val tmp = res[now]\n if(tmpmap.contains(tmp)) tmpmap[tmp] = tmpmap[tmp]!! + 1L\n else tmpmap[tmp] = 1L\n now /= tmp\n }\n for (key in tmpmap.keys) {\n if(map.contains(key) && map[key]!! < tmpmap[key]!!) map[key] = tmpmap[key]!!\n else if (!map.contains(key)) map[key] = tmpmap[key]!!\n }\n }\n\n var lcm = 1L\n for (key in map.keys) {\n lcm = lcm * modpow(key, map[key]!!) % MOD\n }\n\n var ans = 0L\n for (i in a.indices) {\n val b = lcm * modinv(a[i]) % MOD\n ans = modAdd(ans, b)\n }\n\n println(ans)\n\n}\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1590122373, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02793.html", "problem_id": "p02793", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02793/input.txt", "sample_output_relpath": "derived/input_output/data/p02793/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02793/Kotlin/s057192083.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s057192083", "user_id": "u581625805"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val a = nextLongAry(n)\n val res = erathos(1000000)\n val map = map()\n for (i in a.indices) {\n val tmpmap = map()\n var now = a[i]\n while (res[now] != -1L) {\n val tmp = res[now]\n if(tmpmap.contains(tmp)) tmpmap[tmp] = tmpmap[tmp]!! + 1L\n else tmpmap[tmp] = 1L\n now /= tmp\n }\n for (key in tmpmap.keys) {\n if(map.contains(key) && map[key]!! < tmpmap[key]!!) map[key] = tmpmap[key]!!\n else if (!map.contains(key)) map[key] = tmpmap[key]!!\n }\n }\n\n var lcm = 1L\n for (key in map.keys) {\n lcm = lcm * modpow(key, map[key]!!) % MOD\n }\n\n var ans = 0L\n for (i in a.indices) {\n val b = lcm * modinv(a[i]) % MOD\n ans = modAdd(ans, b)\n }\n\n println(ans)\n\n}\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n2 3 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02793", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 18389, "cpu_time_ms": 521, "memory_kb": 51424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s076159096", "group_id": "codeNet:p02793", "input_text": "import java.util.Scanner\n\nclass ModInt {\n\tvar v: Long\n\t\tprivate set\n\tconstructor(v: Int){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v.toLong() % MOD\n\t\t\tv==Int.MIN_VALUE -> 852516373\n\t\t\telse -> MOD.toLong() - (-v%MOD)\n\t\t}\n\t}\n\tconstructor(v: Long){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v % MOD\n\t\t\tv==Long.MIN_VALUE -> 708828003\n\t\t\telse -> MOD - (-v%MOD)\n\t\t}\n\t}\n\n\toverride fun toString() = v.toString()\n\tfun toInt() = v.toInt()\n\tfun toLong() = v\n\toverride fun equals(other: Any?): Boolean {\n\t\treturn if (other is ModInt) v == other.v else false\n\t}\n\toverride fun hashCode() = v.hashCode()\n\n\toperator fun unaryPlus() = this\n\toperator fun unaryMinus() = ModInt(MOD-this.v)\n\n\tprivate operator fun plus(o: Long) = ModInt(this.v + o)\n\toperator fun plus(o: ModInt) = this.plus(o.v)\n\toperator fun plus(o: Int) = this.plus(o.toLong())\n\tprivate operator fun minus(o: Long) = this.plus(-o)\n\toperator fun minus(o: ModInt) = this.minus(o.v)\n\toperator fun minus(o: Int) = this.minus(o.toLong())\n\tprivate operator fun times(o: Long) = ModInt(this.v*o)\n\toperator fun times(o: ModInt) = this.times(o.v)\n\toperator fun times(o: Int) = this.times(o.toLong())\n\tprivate operator fun div(o: Long) = this.times(pow(o, MOD-2))\n\toperator fun div(o: ModInt) = this.div(o.v)\n\toperator fun div(o: Int) = this.div(o.toLong())\n\n\toperator fun inc() = this.plus(1)\n\toperator fun dec() = this.minus(1)\n\n\tcompanion object{\n\t\tconst val MOD = 1000000007\n\n\t\tprivate fun pow(b:Long, e: Int): ModInt{\n\t\t\tif (b==1L) return ModInt(1)\n\t\t\tvar ans = 1L\n\t\t\tvar b = b; var e = e\n\t\t\twhile (e!=0){\n\t\t\t\tif (e%2==1) ans = (ans*b)%MOD\n\t\t\t\tb = (b*b)%MOD\n\t\t\t\te /= 2\n\t\t\t}\n\t\t\treturn ModInt(ans)\n\t\t}\n\t\tfun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)\n\t\tfun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)\n\t}\n}\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval lpf = mutableMapOf()\n\tval pfArr = mutableListOf>()\n\trepeat(n){\n\t\tval a = scn.nextInt()\n\t\tval pf = pFact(a)\n\t\tpfArr.add(pf)\n\t\tpf.forEach {\n\t\t\tlpf[it.key] = Math.max(lpf.getOrElse(it.key){0}, it.value)\n\t\t}\n\t}\n\tvar ans = ModInt(0)\n\tpfArr.forEach { pf ->\n\t\tvar b = ModInt(1)\n\t\tlpf.forEach {\n\t\t\tb *= ModInt.pow(it.key, it.value-pf.getOrElse(it.key){0})\n\t\t}\n\t\tans += b\n\t}\n\tprintln(ans)\n}\n\nfun pFact(n: Int): Map{\n\tvar n = n\n\tval ans = mutableMapOf()\n\tvar i = 2\n\twhile (i*i<=n){\n\t\tif (n%i==0){\n\t\t\tans[i] = ans.getOrElse(i){0} + 1\n\t\t\tn /= i\n\t\t}else i++\n\t}\n\tif (n!=1) ans[n] = ans.getOrElse(n){0}+1\n\treturn ans\n}\n", "language": "Kotlin", "metadata": {"date": 1579472811, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02793.html", "problem_id": "p02793", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02793/input.txt", "sample_output_relpath": "derived/input_output/data/p02793/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02793/Kotlin/s076159096.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s076159096", "user_id": "u914590612"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "import java.util.Scanner\n\nclass ModInt {\n\tvar v: Long\n\t\tprivate set\n\tconstructor(v: Int){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v.toLong() % MOD\n\t\t\tv==Int.MIN_VALUE -> 852516373\n\t\t\telse -> MOD.toLong() - (-v%MOD)\n\t\t}\n\t}\n\tconstructor(v: Long){\n\t\tthis.v = when {\n\t\t\tv>=0 -> v % MOD\n\t\t\tv==Long.MIN_VALUE -> 708828003\n\t\t\telse -> MOD - (-v%MOD)\n\t\t}\n\t}\n\n\toverride fun toString() = v.toString()\n\tfun toInt() = v.toInt()\n\tfun toLong() = v\n\toverride fun equals(other: Any?): Boolean {\n\t\treturn if (other is ModInt) v == other.v else false\n\t}\n\toverride fun hashCode() = v.hashCode()\n\n\toperator fun unaryPlus() = this\n\toperator fun unaryMinus() = ModInt(MOD-this.v)\n\n\tprivate operator fun plus(o: Long) = ModInt(this.v + o)\n\toperator fun plus(o: ModInt) = this.plus(o.v)\n\toperator fun plus(o: Int) = this.plus(o.toLong())\n\tprivate operator fun minus(o: Long) = this.plus(-o)\n\toperator fun minus(o: ModInt) = this.minus(o.v)\n\toperator fun minus(o: Int) = this.minus(o.toLong())\n\tprivate operator fun times(o: Long) = ModInt(this.v*o)\n\toperator fun times(o: ModInt) = this.times(o.v)\n\toperator fun times(o: Int) = this.times(o.toLong())\n\tprivate operator fun div(o: Long) = this.times(pow(o, MOD-2))\n\toperator fun div(o: ModInt) = this.div(o.v)\n\toperator fun div(o: Int) = this.div(o.toLong())\n\n\toperator fun inc() = this.plus(1)\n\toperator fun dec() = this.minus(1)\n\n\tcompanion object{\n\t\tconst val MOD = 1000000007\n\n\t\tprivate fun pow(b:Long, e: Int): ModInt{\n\t\t\tif (b==1L) return ModInt(1)\n\t\t\tvar ans = 1L\n\t\t\tvar b = b; var e = e\n\t\t\twhile (e!=0){\n\t\t\t\tif (e%2==1) ans = (ans*b)%MOD\n\t\t\t\tb = (b*b)%MOD\n\t\t\t\te /= 2\n\t\t\t}\n\t\t\treturn ModInt(ans)\n\t\t}\n\t\tfun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)\n\t\tfun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)\n\t}\n}\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval lpf = mutableMapOf()\n\tval pfArr = mutableListOf>()\n\trepeat(n){\n\t\tval a = scn.nextInt()\n\t\tval pf = pFact(a)\n\t\tpfArr.add(pf)\n\t\tpf.forEach {\n\t\t\tlpf[it.key] = Math.max(lpf.getOrElse(it.key){0}, it.value)\n\t\t}\n\t}\n\tvar ans = ModInt(0)\n\tpfArr.forEach { pf ->\n\t\tvar b = ModInt(1)\n\t\tlpf.forEach {\n\t\t\tb *= ModInt.pow(it.key, it.value-pf.getOrElse(it.key){0})\n\t\t}\n\t\tans += b\n\t}\n\tprintln(ans)\n}\n\nfun pFact(n: Int): Map{\n\tvar n = n\n\tval ans = mutableMapOf()\n\tvar i = 2\n\twhile (i*i<=n){\n\t\tif (n%i==0){\n\t\t\tans[i] = ans.getOrElse(i){0} + 1\n\t\t\tn /= i\n\t\t}else i++\n\t}\n\tif (n!=1) ans[n] = ans.getOrElse(n){0}+1\n\treturn ans\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n2 3 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02793", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2471, "cpu_time_ms": 2111, "memory_kb": 120740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s295653840", "group_id": "codeNet:p02795", "input_text": "fun main(args: Array) {\n val h = readLine()!!.toInt()\n val w = readLine()!!.toInt()\n val n = readLine()!!.toInt()\n val max = Math.max(w,h)\n println(Math.ceil(n.toDouble()/max.toDouble()).toLong())\n}", "language": "Kotlin", "metadata": {"date": 1579378268, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02795.html", "problem_id": "p02795", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02795/input.txt", "sample_output_relpath": "derived/input_output/data/p02795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02795/Kotlin/s295653840.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295653840", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val h = readLine()!!.toInt()\n val w = readLine()!!.toInt()\n val n = readLine()!!.toInt()\n val max = Math.max(w,h)\n println(Math.ceil(n.toDouble()/max.toDouble()).toLong())\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "sample_input": "3\n7\n10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02795", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 205, "memory_kb": 29816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s209244957", "group_id": "codeNet:p02795", "input_text": "fun main(args: Array) {\n val row = readLine()!!.toInt()\n val col = readLine()!!.toInt()\n val n = readLine()!!.toInt()\n println(n / Math.max(row, col))\n}", "language": "Kotlin", "metadata": {"date": 1579377957, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02795.html", "problem_id": "p02795", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02795/input.txt", "sample_output_relpath": "derived/input_output/data/p02795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02795/Kotlin/s209244957.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s209244957", "user_id": "u895858420"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val row = readLine()!!.toInt()\n val col = readLine()!!.toInt()\n val n = readLine()!!.toInt()\n println(n / Math.max(row, col))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "sample_input": "3\n7\n10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02795", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 203, "memory_kb": 29980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s357413715", "group_id": "codeNet:p02796", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val n = nextLong()\n val hand = longAry2(n, 2) // left, right\n for (i in 0 until n) {\n val x = nextLong()\n val l = nextLong()\n hand[i][0] = x - l\n hand[i][1] = x + l\n }\n hand.sortBy { it[1] }\n\n var ans = 0L\n var maxRight = -INF\n for (i in 0 until n) {\n if(hand[i][0] < maxRight) continue\n maxRight = hand[i][1]\n ans++\n }\n\n println(ans)\n\n}\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1588423382, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/Kotlin/s357413715.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357413715", "user_id": "u581625805"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val n = nextLong()\n val hand = longAry2(n, 2) // left, right\n for (i in 0 until n) {\n val x = nextLong()\n val l = nextLong()\n hand[i][0] = x - l\n hand[i][1] = x + l\n }\n hand.sortBy { it[1] }\n\n var ans = 0L\n var maxRight = -INF\n for (i in 0 until n) {\n if(hand[i][0] < maxRight) continue\n maxRight = hand[i][1]\n ans++\n }\n\n println(ans)\n\n}\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14605, "cpu_time_ms": 725, "memory_kb": 57568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s520141312", "group_id": "codeNet:p02796", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val xl = (0 until n).map { sc.next().toLong() to sc.next().toLong() }\n println(problem2020b(n, xl))\n}\n\nfun problem2020b(n: Int, xl: List>): Int {\n val xl = xl.sortedBy { it.first + it.second - 1 }\n var count = 0\n var removedCount = 0\n for (i in 1 until n) {\n val prev = xl[i - 1 - removedCount].first + xl[i - 1 - removedCount].second - 1\n val current = xl[i].first - xl[i].second + 1\n if (prev >= current) {\n count++\n if (prev < xl[i].first + xl[i].second - 1) {\n removedCount++\n } else {\n removedCount = 0\n }\n } else {\n removedCount = 0\n }\n }\n return n - count\n}", "language": "Kotlin", "metadata": {"date": 1579428116, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/Kotlin/s520141312.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s520141312", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val xl = (0 until n).map { sc.next().toLong() to sc.next().toLong() }\n println(problem2020b(n, xl))\n}\n\nfun problem2020b(n: Int, xl: List>): Int {\n val xl = xl.sortedBy { it.first + it.second - 1 }\n var count = 0\n var removedCount = 0\n for (i in 1 until n) {\n val prev = xl[i - 1 - removedCount].first + xl[i - 1 - removedCount].second - 1\n val current = xl[i].first - xl[i].second + 1\n if (prev >= current) {\n count++\n if (prev < xl[i].first + xl[i].second - 1) {\n removedCount++\n } else {\n removedCount = 0\n }\n } else {\n removedCount = 0\n }\n }\n return n - count\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 837, "cpu_time_ms": 864, "memory_kb": 88648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s252319586", "group_id": "codeNet:p02796", "input_text": "fun main(args: Array) {\n val N = nextInt()\n val A = mutableListOf>()\n var min = Int.MAX_VALUE\n var max = Int.MIN_VALUE\n for (n in 0 until N) {\n val (x, l) = listOfInt()\n val L = x - l + 1\n val R = x + l - 1\n if (L < min) min = L\n if (max < R) max = R\n A.add(Pair(L, R))\n }\n val OFFSET = -min\n val B = Array(max - min + 1) { 0 }\n A.forEach {\n for (i in it.first .. it.second) {\n B[i + OFFSET] += 1\n }\n }\n var dup = B.max() ?: 0\n println(N - dup + 1)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }", "language": "Kotlin", "metadata": {"date": 1579382418, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/Kotlin/s252319586.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s252319586", "user_id": "u911700901"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextInt()\n val A = mutableListOf>()\n var min = Int.MAX_VALUE\n var max = Int.MIN_VALUE\n for (n in 0 until N) {\n val (x, l) = listOfInt()\n val L = x - l + 1\n val R = x + l - 1\n if (L < min) min = L\n if (max < R) max = R\n A.add(Pair(L, R))\n }\n val OFFSET = -min\n val B = Array(max - min + 1) { 0 }\n A.forEach {\n for (i in it.first .. it.second) {\n B[i + OFFSET] += 1\n }\n }\n var dup = B.max() ?: 0\n println(N - dup + 1)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 793, "cpu_time_ms": 2110, "memory_kb": 134024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s948637529", "group_id": "codeNet:p02797", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val s = sc.nextInt()\n\n\n val list = mutableListOf()\n for (i in 0 until n) {\n if (i < k) {\n list.add(s)\n } else {\n list.add(s+1)\n }\n }\n\n println(list.joinToString(\" \"))\n\n}", "language": "Kotlin", "metadata": {"date": 1597517547, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02797/input.txt", "sample_output_relpath": "derived/input_output/data/p02797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02797/Kotlin/s948637529.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s948637529", "user_id": "u323522006"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val s = sc.nextInt()\n\n\n val list = mutableListOf()\n for (i in 0 until n) {\n if (i < k) {\n list.add(s)\n } else {\n list.add(s+1)\n }\n }\n\n println(list.joinToString(\" \"))\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "sample_input": "4 2 3\n"}, "reference_outputs": ["1 2 3 4\n"], "source_document_id": "p02797", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 329, "cpu_time_ms": 249, "memory_kb": 52348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s783118196", "group_id": "codeNet:p02797", "input_text": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (n, k, s) = readStringList()\n val a = mutableListOf()\n repeat(k.toInt()) {\n a += s\n }\n repeat (n.toInt() - k.toInt()) {\n a += if (s.toInt() == 1000000000) \"1\" else \"1000000000\"\n }\n println(a.joinToString(\" \"))\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1588461083, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02797/input.txt", "sample_output_relpath": "derived/input_output/data/p02797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02797/Kotlin/s783118196.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s783118196", "user_id": "u784448849"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val (n, k, s) = readStringList()\n val a = mutableListOf()\n repeat(k.toInt()) {\n a += s\n }\n repeat (n.toInt() - k.toInt()) {\n a += if (s.toInt() == 1000000000) \"1\" else \"1000000000\"\n }\n println(a.joinToString(\" \"))\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "sample_input": "4 2 3\n"}, "reference_outputs": ["1 2 3 4\n"], "source_document_id": "p02797", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 747, "cpu_time_ms": 344, "memory_kb": 40912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s822591426", "group_id": "codeNet:p02797", "input_text": "fun main(args : Array) {\n val (n, k, s) = readLine()!!.split(\" \").map { it.toInt() }\n val ans = mutableListOf()\n\n if (k == 0) {\n repeat(n) {\n ans.add(s+1)\n }\n println(ans.joinToString(separator = \" \"))\n return\n }\n\n repeat(k) {\n ans.add(s)\n }\n repeat(n-k) {\n ans.add(0)\n }\n println(ans.joinToString(separator = \" \"))\n}", "language": "Kotlin", "metadata": {"date": 1579384050, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02797/input.txt", "sample_output_relpath": "derived/input_output/data/p02797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02797/Kotlin/s822591426.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s822591426", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, k, s) = readLine()!!.split(\" \").map { it.toInt() }\n val ans = mutableListOf()\n\n if (k == 0) {\n repeat(n) {\n ans.add(s+1)\n }\n println(ans.joinToString(separator = \" \"))\n return\n }\n\n repeat(k) {\n ans.add(s)\n }\n repeat(n-k) {\n ans.add(0)\n }\n println(ans.joinToString(separator = \" \"))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "sample_input": "4 2 3\n"}, "reference_outputs": ["1 2 3 4\n"], "source_document_id": "p02797", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 410, "cpu_time_ms": 354, "memory_kb": 46516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s269545634", "group_id": "codeNet:p02801", "input_text": "fun solve(S: String) {\n val alp = \"abcdefghijklmnopqrstuvwxyz\"\n repeat(26) {\n// println(it)\n if (alp[it].toString() == S) {\n println(alp[(it + 1) % 26])\n }\n }\n}\n\nfun main() {\n val S = readLine()!!\n// val N = readLine()!!.toInt()\n// val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(S)\n}", "language": "Kotlin", "metadata": {"date": 1598834145, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Kotlin/s269545634.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s269545634", "user_id": "u945228737"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun solve(S: String) {\n val alp = \"abcdefghijklmnopqrstuvwxyz\"\n repeat(26) {\n// println(it)\n if (alp[it].toString() == S) {\n println(alp[(it + 1) % 26])\n }\n }\n}\n\nfun main() {\n val S = readLine()!!\n// val N = readLine()!!.toInt()\n// val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n// val A = readLine()!!.split(\" \").map { it.toInt() }\n solve(S)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 409, "cpu_time_ms": 106, "memory_kb": 34396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s674524168", "group_id": "codeNet:p02801", "input_text": "fun main(args:Array){\n val a=readLine()!!\n val b=\"abcdefghijklmnopqrstuvwxyz\"\n for (i in 1..25){\n if (a == b[i].toString()){\n println(\"${b[i+1]}\")\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1586858341, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Kotlin/s674524168.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s674524168", "user_id": "u387080888"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args:Array){\n val a=readLine()!!\n val b=\"abcdefghijklmnopqrstuvwxyz\"\n for (i in 1..25){\n if (a == b[i].toString()){\n println(\"${b[i+1]}\")\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 202, "memory_kb": 31596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s604005515", "group_id": "codeNet:p02801", "input_text": "fun main(args: Array) {\n val c = readLine()!![0]\n println(c.inc())\n}\n", "language": "Kotlin", "metadata": {"date": 1578859257, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Kotlin/s604005515.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604005515", "user_id": "u863309603"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args: Array) {\n val c = readLine()!![0]\n println(c.inc())\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 83, "cpu_time_ms": 209, "memory_kb": 29876}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s336780962", "group_id": "codeNet:p02802", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val pairs = mutableListOf>()\n\n for (i in 0 until m) {\n val (id, result) = readLine()!!.split(\" \")\n pairs.add(Pair(id.toInt(), result))\n }\n\n var wa = 0\n var ac = 0\n\n val rows = mutableListOf>()\n for (j in 1 until n+1) {\n val row = pairs.filter { it.first == j}.map { it.second }\n\n wa += pairs.filter { it.first == j }.takeWhile { it.second == \"WA\" }.filter { it.second == \"WA\" }.size\n if (pairs.filter{it.first == j}.filter{it.second == \"AC\"}.isNotEmpty()) ac += 1\n\n rows.add(row)\n }\n\n println(\"$ac $wa\")\n}", "language": "Kotlin", "metadata": {"date": 1579131902, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02802/input.txt", "sample_output_relpath": "derived/input_output/data/p02802/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02802/Kotlin/s336780962.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s336780962", "user_id": "u944015274"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val pairs = mutableListOf>()\n\n for (i in 0 until m) {\n val (id, result) = readLine()!!.split(\" \")\n pairs.add(Pair(id.toInt(), result))\n }\n\n var wa = 0\n var ac = 0\n\n val rows = mutableListOf>()\n for (j in 1 until n+1) {\n val row = pairs.filter { it.first == j}.map { it.second }\n\n wa += pairs.filter { it.first == j }.takeWhile { it.second == \"WA\" }.filter { it.second == \"WA\" }.size\n if (pairs.filter{it.first == j}.filter{it.second == \"AC\"}.isNotEmpty()) ac += 1\n\n rows.add(row)\n }\n\n println(\"$ac $wa\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 698, "cpu_time_ms": 2111, "memory_kb": 62644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s245106814", "group_id": "codeNet:p02802", "input_text": "fun main(args: Array) {\n val (N, M) = readInts()\n val waCnt = Array(N) { 0 }\n val isAc = Array(N) { false }\n repeat(M) {\n val (P, S) = readStrings()\n val p = P.toInt() - 1\n if (S == \"AC\") {\n isAc[p] = true\n } else {\n if (!isAc[p]) waCnt[p]++\n }\n }\n var ac = 0\n var pn = 0\n for (i in 0 until N) {\n if (isAc[i]) {\n ac++\n pn += waCnt[i]\n }\n }\n println(\"$ac $pn\")\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "language": "Kotlin", "metadata": {"date": 1578881841, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02802/input.txt", "sample_output_relpath": "derived/input_output/data/p02802/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02802/Kotlin/s245106814.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s245106814", "user_id": "u979004569"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M) = readInts()\n val waCnt = Array(N) { 0 }\n val isAc = Array(N) { false }\n repeat(M) {\n val (P, S) = readStrings()\n val p = P.toInt() - 1\n if (S == \"AC\") {\n isAc[p] = true\n } else {\n if (!isAc[p]) waCnt[p]++\n }\n }\n var ac = 0\n var pn = 0\n for (i in 0 until N) {\n if (isAc[i]) {\n ac++\n pn += waCnt[i]\n }\n }\n println(\"$ac $pn\")\n}\n\nfun readString() = readLine()!!\nfun readStrings() = readString().split(\" \")\nfun readInt() = readString().toInt()\nfun readInts() = readStrings().map { it.toInt() }\nfun readLongs() = readStrings().map { it.toLong() }\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 637, "cpu_time_ms": 563, "memory_kb": 56116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s108805179", "group_id": "codeNet:p02803", "input_text": "fun main(args: Array) {\n val dx = listOf(1, 0, -1, 0)\n val dy = listOf(0, 1, 0, -1)\n val (H, W) = listOfInt()\n var maze = Array(H) { next() }\n fun xfs(sh: Int, sw: Int): Int {\n var result = 0\n var Q = Queue>()\n var visit = Array(H) { IntArray(W) { -1 } }\n Q.enqueue(Triple(sh, sw, 0))\n visit[sh][sw] = 0\n while (!Q.isEmpty()) {\n val q = Q.dequeue()!!\n val h = q.first\n val w = q.second\n val k = q.third\n visit[h][w] = k\n if (result < k) result = k\n for (n in 0 .. 3) {\n val nh = h + dx[n]\n val nw = w + dy[n]\n if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue\n if (maze[nh][nw] == '#') continue\n if (visit[nh][nw] != -1) continue\n Q.enqueue(Triple(nh, nw, k + 1))\n }\n }\n return result\n }\n var ans = 0\n for (h in 0 until H) {\n for (w in 0 until W) {\n if (maze[h][w] == '#') continue\n val len = xfs(h, w)\n ans = Math.max(ans, len)\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nclass Queue {\n val elements = mutableListOf()\n fun isEmpty() = elements.isEmpty()\n fun enqueue(item: T) = elements.add(item)\n fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null\n override fun toString(): String = elements.toString()\n}\nfun Queue.push(items: Collection) = items.forEach { this.enqueue(it) }", "language": "Kotlin", "metadata": {"date": 1579131825, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02803.html", "problem_id": "p02803", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02803/input.txt", "sample_output_relpath": "derived/input_output/data/p02803/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02803/Kotlin/s108805179.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s108805179", "user_id": "u043150661"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val dx = listOf(1, 0, -1, 0)\n val dy = listOf(0, 1, 0, -1)\n val (H, W) = listOfInt()\n var maze = Array(H) { next() }\n fun xfs(sh: Int, sw: Int): Int {\n var result = 0\n var Q = Queue>()\n var visit = Array(H) { IntArray(W) { -1 } }\n Q.enqueue(Triple(sh, sw, 0))\n visit[sh][sw] = 0\n while (!Q.isEmpty()) {\n val q = Q.dequeue()!!\n val h = q.first\n val w = q.second\n val k = q.third\n visit[h][w] = k\n if (result < k) result = k\n for (n in 0 .. 3) {\n val nh = h + dx[n]\n val nw = w + dy[n]\n if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue\n if (maze[nh][nw] == '#') continue\n if (visit[nh][nw] != -1) continue\n Q.enqueue(Triple(nh, nw, k + 1))\n }\n }\n return result\n }\n var ans = 0\n for (h in 0 until H) {\n for (w in 0 until W) {\n if (maze[h][w] == '#') continue\n val len = xfs(h, w)\n ans = Math.max(ans, len)\n }\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nclass Queue {\n val elements = mutableListOf()\n fun isEmpty() = elements.isEmpty()\n fun enqueue(item: T) = elements.add(item)\n fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null\n override fun toString(): String = elements.toString()\n}\nfun Queue.push(items: Collection) = items.forEach { this.enqueue(it) }", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "sample_input": "3 3\n...\n...\n...\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02803", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1709, "cpu_time_ms": 2111, "memory_kb": 41776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s362501324", "group_id": "codeNet:p02803", "input_text": "import java.util.*\n\ndata class Point(val x: Int, val y: Int)\n\nfun main(args: Array) {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val s = (1..H).map { readLine()!!.map { it == '.' } }\n val sy = s.indexOfFirst { it.contains(true) }\n val sx = s[sy].indexOfFirst { it }\n\n val dist = Array(H) { i -> IntArray(W) { j -> if (s[i][j]) 100000 else -1 } }\n dist[sy][sx] = 0\n\n val q = ArrayDeque()\n q.offer(Point(sx, sy))\n while (q.isNotEmpty()) {\n val p = q.poll()\n if (p.y != 0 && s[p.y - 1][p.x] && dist[p.y - 1][p.x] > dist[p.y][p.x] + 1) {\n dist[p.y - 1][p.x] = dist[p.y][p.x] + 1\n q.offer(Point(p.x, p.y - 1))\n }\n if (p.y != H - 1 && s[p.y + 1][p.x] && dist[p.y + 1][p.x] > dist[p.y][p.x] + 1) {\n dist[p.y + 1][p.x] = dist[p.y][p.x] + 1\n q.offer(Point(p.x, p.y + 1))\n }\n if (p.x != 0 && s[p.y][p.x - 1] && dist[p.y][p.x - 1] > dist[p.y][p.x] + 1) {\n dist[p.y][p.x - 1] = dist[p.y][p.x] + 1\n q.offer(Point(p.x - 1, p.y))\n }\n if (p.x != W - 1 && s[p.y][p.x + 1] && dist[p.y][p.x + 1] > dist[p.y][p.x] + 1) {\n dist[p.y][p.x + 1] = dist[p.y][p.x] + 1\n q.offer(Point(p.x + 1, p.y))\n }\n }\n\n val max = dist.map { it.max()!! }.max()!!\n val sy2 = dist.indexOfFirst { it.contains(max) }\n val sx2 = dist[sy2].indexOfFirst { it == max }\n\n val dist2 = Array(H) { i -> IntArray(W) { j -> if (s[i][j]) 1000 else -1 } }\n dist2[sy2][sx2] = 0\n\n q.offer(Point(sx2, sy2))\n while (q.isNotEmpty()) {\n val p = q.poll()\n if (p.y != 0 && s[p.y - 1][p.x] && dist2[p.y - 1][p.x] > dist2[p.y][p.x] + 1) {\n dist2[p.y - 1][p.x] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x, p.y - 1))\n }\n if (p.y != H - 1 && s[p.y + 1][p.x] && dist2[p.y + 1][p.x] > dist2[p.y][p.x] + 1) {\n dist2[p.y + 1][p.x] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x, p.y + 1))\n }\n if (p.x != 0 && s[p.y][p.x - 1] && dist2[p.y][p.x - 1] > dist2[p.y][p.x] + 1) {\n dist2[p.y][p.x - 1] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x - 1, p.y))\n }\n if (p.x != W - 1 && s[p.y][p.x + 1] && dist2[p.y][p.x + 1] > dist2[p.y][p.x] + 1) {\n dist2[p.y][p.x + 1] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x + 1, p.y))\n }\n }\n\n val ans = dist2.map { it.max()!! }.max()!!\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1578885604, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02803.html", "problem_id": "p02803", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02803/input.txt", "sample_output_relpath": "derived/input_output/data/p02803/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02803/Kotlin/s362501324.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s362501324", "user_id": "u914096045"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\ndata class Point(val x: Int, val y: Int)\n\nfun main(args: Array) {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val s = (1..H).map { readLine()!!.map { it == '.' } }\n val sy = s.indexOfFirst { it.contains(true) }\n val sx = s[sy].indexOfFirst { it }\n\n val dist = Array(H) { i -> IntArray(W) { j -> if (s[i][j]) 100000 else -1 } }\n dist[sy][sx] = 0\n\n val q = ArrayDeque()\n q.offer(Point(sx, sy))\n while (q.isNotEmpty()) {\n val p = q.poll()\n if (p.y != 0 && s[p.y - 1][p.x] && dist[p.y - 1][p.x] > dist[p.y][p.x] + 1) {\n dist[p.y - 1][p.x] = dist[p.y][p.x] + 1\n q.offer(Point(p.x, p.y - 1))\n }\n if (p.y != H - 1 && s[p.y + 1][p.x] && dist[p.y + 1][p.x] > dist[p.y][p.x] + 1) {\n dist[p.y + 1][p.x] = dist[p.y][p.x] + 1\n q.offer(Point(p.x, p.y + 1))\n }\n if (p.x != 0 && s[p.y][p.x - 1] && dist[p.y][p.x - 1] > dist[p.y][p.x] + 1) {\n dist[p.y][p.x - 1] = dist[p.y][p.x] + 1\n q.offer(Point(p.x - 1, p.y))\n }\n if (p.x != W - 1 && s[p.y][p.x + 1] && dist[p.y][p.x + 1] > dist[p.y][p.x] + 1) {\n dist[p.y][p.x + 1] = dist[p.y][p.x] + 1\n q.offer(Point(p.x + 1, p.y))\n }\n }\n\n val max = dist.map { it.max()!! }.max()!!\n val sy2 = dist.indexOfFirst { it.contains(max) }\n val sx2 = dist[sy2].indexOfFirst { it == max }\n\n val dist2 = Array(H) { i -> IntArray(W) { j -> if (s[i][j]) 1000 else -1 } }\n dist2[sy2][sx2] = 0\n\n q.offer(Point(sx2, sy2))\n while (q.isNotEmpty()) {\n val p = q.poll()\n if (p.y != 0 && s[p.y - 1][p.x] && dist2[p.y - 1][p.x] > dist2[p.y][p.x] + 1) {\n dist2[p.y - 1][p.x] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x, p.y - 1))\n }\n if (p.y != H - 1 && s[p.y + 1][p.x] && dist2[p.y + 1][p.x] > dist2[p.y][p.x] + 1) {\n dist2[p.y + 1][p.x] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x, p.y + 1))\n }\n if (p.x != 0 && s[p.y][p.x - 1] && dist2[p.y][p.x - 1] > dist2[p.y][p.x] + 1) {\n dist2[p.y][p.x - 1] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x - 1, p.y))\n }\n if (p.x != W - 1 && s[p.y][p.x + 1] && dist2[p.y][p.x + 1] > dist2[p.y][p.x] + 1) {\n dist2[p.y][p.x + 1] = dist2[p.y][p.x] + 1\n q.offer(Point(p.x + 1, p.y))\n }\n }\n\n val ans = dist2.map { it.max()!! }.max()!!\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "sample_input": "3 3\n...\n...\n...\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02803", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2483, "cpu_time_ms": 250, "memory_kb": 37820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s816589690", "group_id": "codeNet:p02807", "input_text": "fun main(args: Array) {\n dwacon6thPrelimsB()\n}\n\nfun dwacon6thPrelimsB() {\n val n = readLine()!!.toInt()\n val xList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()\n\n val diffs = LongArray(n - 1)\n for (i in 0 until n - 1) diffs[i] = xList[i + 1] - xList[i]\n\n var answer = Mint(0)\n var c = Mint(0)\n\n nCkInit()\n\n for (i in diffs.indices) {\n c += inv[i + 1]\n answer += c * diffs[i]\n }\n\n answer *= fac[n - 1]\n\n println(answer)\n}\n\nprivate const val MOD = (1e9 + 7).toLong()\n\nprivate const val MAX = 1000000\nprivate val fac = LongArray(MAX)\nprivate val fInv = LongArray(MAX)\nprivate val inv = LongArray(MAX)\n\nprivate fun nCkInit() {\n fac[0] = 1\n fac[1] = 1\n fInv[0] = 1\n fInv[1] = 1\n inv[1] = 1\n for (i in 2 until MAX) {\n fac[i] = fac[i - 1] * i % MOD\n inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD\n fInv[i] = fInv[i - 1] * inv[i] % MOD\n }\n}\n\nprivate class Mint(value: Long) {\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * other)\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = Mint(modPow(other, MOD - 2, MOD))\n operator fun div(other: Mint) = this.div(other.value)\n override fun toString(): String {\n return this.value.toString()\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n\n other as Mint\n\n if (value != other.value) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n return value.hashCode()\n }\n\n @Suppress(\"SameParameterValue\")\n companion object Mod {\n private fun modPow(n: Long, p: Long, m: Long): Long {\n var x = n\n var y = p\n var result = 1L\n x %= m\n while (y > 0) {\n if (y % 2 == 1L)\n result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n return result\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1578954850, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02807.html", "problem_id": "p02807", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02807/input.txt", "sample_output_relpath": "derived/input_output/data/p02807/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02807/Kotlin/s816589690.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816589690", "user_id": "u139478771"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n dwacon6thPrelimsB()\n}\n\nfun dwacon6thPrelimsB() {\n val n = readLine()!!.toInt()\n val xList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()\n\n val diffs = LongArray(n - 1)\n for (i in 0 until n - 1) diffs[i] = xList[i + 1] - xList[i]\n\n var answer = Mint(0)\n var c = Mint(0)\n\n nCkInit()\n\n for (i in diffs.indices) {\n c += inv[i + 1]\n answer += c * diffs[i]\n }\n\n answer *= fac[n - 1]\n\n println(answer)\n}\n\nprivate const val MOD = (1e9 + 7).toLong()\n\nprivate const val MAX = 1000000\nprivate val fac = LongArray(MAX)\nprivate val fInv = LongArray(MAX)\nprivate val inv = LongArray(MAX)\n\nprivate fun nCkInit() {\n fac[0] = 1\n fac[1] = 1\n fInv[0] = 1\n fInv[1] = 1\n inv[1] = 1\n for (i in 2 until MAX) {\n fac[i] = fac[i - 1] * i % MOD\n inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD\n fInv[i] = fInv[i - 1] * inv[i] % MOD\n }\n}\n\nprivate class Mint(value: Long) {\n private val value = if (value < 0) (value % MOD) + MOD else value % MOD\n operator fun unaryPlus() = this\n operator fun unaryMinus() = Mint(MOD - this.value)\n operator fun inc() = this.plus(1)\n operator fun dec() = this.minus(1)\n operator fun plus(other: Long) = Mint(this.value + other)\n operator fun plus(other: Mint) = this.plus(other.value)\n operator fun minus(other: Long) = Mint(this.value - other)\n operator fun minus(other: Mint) = this.plus(-other)\n operator fun times(other: Long) = Mint(this.value * other)\n operator fun times(other: Mint) = this.times(other.value)\n operator fun div(other: Long) = Mint(modPow(other, MOD - 2, MOD))\n operator fun div(other: Mint) = this.div(other.value)\n override fun toString(): String {\n return this.value.toString()\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n\n other as Mint\n\n if (value != other.value) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n return value.hashCode()\n }\n\n @Suppress(\"SameParameterValue\")\n companion object Mod {\n private fun modPow(n: Long, p: Long, m: Long): Long {\n var x = n\n var y = p\n var result = 1L\n x %= m\n while (y > 0) {\n if (y % 2 == 1L)\n result = (result * x) % m\n y = y shr 1\n x = (x * x) % m\n }\n return result\n }\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N slimes standing on a number line.\nThe i-th slime from the left is at position x_i.\n\nIt is guaruanteed that 1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}.\n\nNiwango will perform N-1 operations. The i-th operation consists of the following procedures:\n\nChoose an integer k between 1 and N-i (inclusive) with equal probability.\n\nMove the k-th slime from the left, to the position of the neighboring slime to the right.\n\nFuse the two slimes at the same position into one slime.\n\nFind the total distance traveled by the slimes multiplied by (N-1)! (we can show that this value is an integer), modulo (10^{9}+7). If a slime is born by a fuse and that slime moves, we count it as just one slime.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}\n\nx_i is an integer.\n\nSubtasks\n\n400 points will be awarded for passing the test cases satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 x_2 \\ldots x_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n5\n\nWith probability \\frac{1}{2}, the leftmost slime is chosen in the first operation, in which case the total distance traveled is 2.\n\nWith probability \\frac{1}{2}, the middle slime is chosen in the first operation, in which case the total distance traveled is 3.\n\nThe answer is the expected total distance traveled, 2.5, multiplied by 2!, which is 5.\n\nSample Input 2\n\n12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932\n\nSample Output 2\n\n750927044\n\nFind the expected value multiplied by (N-1)!, modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02807", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N slimes standing on a number line.\nThe i-th slime from the left is at position x_i.\n\nIt is guaruanteed that 1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}.\n\nNiwango will perform N-1 operations. The i-th operation consists of the following procedures:\n\nChoose an integer k between 1 and N-i (inclusive) with equal probability.\n\nMove the k-th slime from the left, to the position of the neighboring slime to the right.\n\nFuse the two slimes at the same position into one slime.\n\nFind the total distance traveled by the slimes multiplied by (N-1)! (we can show that this value is an integer), modulo (10^{9}+7). If a slime is born by a fuse and that slime moves, we count it as just one slime.\n\nConstraints\n\n2 \\leq N \\leq 10^{5}\n\n1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}\n\nx_i is an integer.\n\nSubtasks\n\n400 points will be awarded for passing the test cases satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 x_2 \\ldots x_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n5\n\nWith probability \\frac{1}{2}, the leftmost slime is chosen in the first operation, in which case the total distance traveled is 2.\n\nWith probability \\frac{1}{2}, the middle slime is chosen in the first operation, in which case the total distance traveled is 3.\n\nThe answer is the expected total distance traveled, 2.5, multiplied by 2!, which is 5.\n\nSample Input 2\n\n12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932\n\nSample Output 2\n\n750927044\n\nFind the expected value multiplied by (N-1)!, modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2569, "cpu_time_ms": 555, "memory_kb": 97112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s278431175", "group_id": "codeNet:p02811", "input_text": "fun main(args: Array) {\n val (k, x) = readLine()!!.split(' ').map(String::toLong)\n\n if (k * 500 >= x) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1578789812, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s278431175.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s278431175", "user_id": "u099066216"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (k, x) = readLine()!!.split(' ').map(String::toLong)\n\n if (k * 500 >= x) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 300, "memory_kb": 36388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s531288269", "group_id": "codeNet:p02811", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n if (500 * a > b) {\n \tprint(\"Yes\")\n } else {\n print(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1578776275, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s531288269.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s531288269", "user_id": "u947375463"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n if (500 * a > b) {\n \tprint(\"Yes\")\n } else {\n print(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 160, "cpu_time_ms": 241, "memory_kb": 36020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s854060582", "group_id": "codeNet:p02811", "input_text": "import java.util.Scanner\n\nfun main(args: Array){\n val scanner = Scanner(System.`in`)\n val sa = scanner.next()\n val sb = scanner.next()\n val a = Integer.parseInt(sa)\n val b = Integer.parseInt(sb)\n val aa = a*500\n if(aa >= b){\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1578711087, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s854060582.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s854060582", "user_id": "u385678999"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array){\n val scanner = Scanner(System.`in`)\n val sa = scanner.next()\n val sb = scanner.next()\n val a = Integer.parseInt(sa)\n val b = Integer.parseInt(sb)\n val aa = a*500\n if(aa >= b){\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 173, "memory_kb": 29468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s169113850", "group_id": "codeNet:p02811", "input_text": "fun main(args: Array) {\n val kx = readLine()!!.split(\" \").map{ it.toInt() }\n if (kx[0] * 500 >= kx[1]) {\n print(\"Yes\")\n } else {\n print(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1578708416, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/Kotlin/s169113850.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s169113850", "user_id": "u069766151"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val kx = readLine()!!.split(\" \").map{ it.toInt() }\n if (kx[0] * 500 >= kx[1]) {\n print(\"Yes\")\n } else {\n print(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 237, "memory_kb": 35940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s051701411", "group_id": "codeNet:p02812", "input_text": "fun main (args:Array){\n var strLen = readLine()!!.toInt()\n var strS = readLine()!!\n var count = 0\n\n while(strLen > 3){\n var abcIndex = strS.indexOf(\"ABC\")\n if(abcIndex == -1){\n return\n }\n else {\n strS = strS.drop((abcIndex + 3))\n count++\n strLen -= abcIndex + 3\n }\n }\n print(count)\n}", "language": "Kotlin", "metadata": {"date": 1595082576, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s051701411.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s051701411", "user_id": "u800824593"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main (args:Array){\n var strLen = readLine()!!.toInt()\n var strS = readLine()!!\n var count = 0\n\n while(strLen > 3){\n var abcIndex = strS.indexOf(\"ABC\")\n if(abcIndex == -1){\n return\n }\n else {\n strS = strS.drop((abcIndex + 3))\n count++\n strLen -= abcIndex + 3\n }\n }\n print(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 388, "cpu_time_ms": 104, "memory_kb": 35936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s568638167", "group_id": "codeNet:p02812", "input_text": "fun main(args: Array) {\n abc150b()\n}\n\nfun abc150b() {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n val answer = Regex(\"ABC\").findAll(s).count()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1578764698, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Kotlin/s568638167.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568638167", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n abc150b()\n}\n\nfun abc150b() {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n val answer = Regex(\"ABC\").findAll(s).count()\n\n println(answer)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 212, "memory_kb": 33696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s875458216", "group_id": "codeNet:p02813", "input_text": "fun main(args: Array) {\n val n = readInteger()\n val pList = readIntegerList().joinToString()\n val qList = readIntegerList().joinToString()\n\n val permutationList = permutationListFrom(Array(n) { it + 1 }).map {\n it.joinToString()\n }\n\n println(Math.abs(permutationList.indexOf(pList) - permutationList.indexOf(qList)))\n\n}\n\nfun > permutationListFrom(array: Array): List> {\n val current = array.copyOf()\n val permutationList = mutableListOf>()\n do {\n permutationList += current.copyOf()\n } while (nextPermutation(current))\n\n return permutationList\n}\n\nfun > nextPermutation(currentPermutation: Array): Boolean {\n fun Array.reverse(start: Int, end: Int) {\n val midPoint = ((start + end) / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = end - 1\n for (index in start..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n }\n\n val n = currentPermutation.size\n\n var i = n - 2\n while (i >= 0) {\n if (currentPermutation[i] < currentPermutation[i + 1]) break\n i--\n }\n\n if (i < 0) return false\n\n var j = n\n do {\n j--\n } while (currentPermutation[i] > currentPermutation[j])\n\n if (currentPermutation[i] < currentPermutation[j]) {\n val tmp = currentPermutation[i]\n currentPermutation[i] = currentPermutation[j]\n currentPermutation[j] = tmp\n currentPermutation.reverse(i + 1, n)\n return true\n }\n\n return false\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1582600083, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02813/input.txt", "sample_output_relpath": "derived/input_output/data/p02813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02813/Kotlin/s875458216.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875458216", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInteger()\n val pList = readIntegerList().joinToString()\n val qList = readIntegerList().joinToString()\n\n val permutationList = permutationListFrom(Array(n) { it + 1 }).map {\n it.joinToString()\n }\n\n println(Math.abs(permutationList.indexOf(pList) - permutationList.indexOf(qList)))\n\n}\n\nfun > permutationListFrom(array: Array): List> {\n val current = array.copyOf()\n val permutationList = mutableListOf>()\n do {\n permutationList += current.copyOf()\n } while (nextPermutation(current))\n\n return permutationList\n}\n\nfun > nextPermutation(currentPermutation: Array): Boolean {\n fun Array.reverse(start: Int, end: Int) {\n val midPoint = ((start + end) / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = end - 1\n for (index in start..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n }\n\n val n = currentPermutation.size\n\n var i = n - 2\n while (i >= 0) {\n if (currentPermutation[i] < currentPermutation[i + 1]) break\n i--\n }\n\n if (i < 0) return false\n\n var j = n\n do {\n j--\n } while (currentPermutation[i] > currentPermutation[j])\n\n if (currentPermutation[i] < currentPermutation[j]) {\n val tmp = currentPermutation[i]\n currentPermutation[i] = currentPermutation[j]\n currentPermutation[j] = tmp\n currentPermutation.reverse(i + 1, n)\n return true\n }\n\n return false\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "sample_input": "3\n1 3 2\n3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02813", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1904, "cpu_time_ms": 551, "memory_kb": 53036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s077342462", "group_id": "codeNet:p02813", "input_text": "fun main(args: Array) {\n fun nextPermutation(arr: IntArray): Boolean {\n var i = arr.size - 1\n while (i > 0 && arr[i - 1] >= arr[i]) {\n i--\n }\n\n if (i <= 0) {\n return false\n }\n\n var j = arr.size - 1\n while (arr[j] <= arr[i - 1]) {\n j--\n }\n\n var temp = arr[i - 1]\n arr[i - 1] = arr[j]\n arr[j] = temp\n\n j = arr.size - 1\n while (i < j) {\n temp = arr[i]\n arr[i] = arr[j]\n arr[j] = temp\n i++\n j--\n }\n\n return true\n }\n\n val N = readLine()!!.toInt()\n\n val PN = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n val QN = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n\n val array = (1..N).toList().toIntArray()\n\n var index = 1\n var a = 0\n var b = 0\n do {\n if (PN.joinToString(\"\") == array.joinToString(\"\")) {\n a = index\n }\n if (QN.joinToString(\"\") == array.joinToString(\"\")) {\n b = index\n }\n index++\n\n } while (nextPermutation(array))\n\n println(Math.abs(a - b))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1578766041, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02813/input.txt", "sample_output_relpath": "derived/input_output/data/p02813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02813/Kotlin/s077342462.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s077342462", "user_id": "u085288971"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n fun nextPermutation(arr: IntArray): Boolean {\n var i = arr.size - 1\n while (i > 0 && arr[i - 1] >= arr[i]) {\n i--\n }\n\n if (i <= 0) {\n return false\n }\n\n var j = arr.size - 1\n while (arr[j] <= arr[i - 1]) {\n j--\n }\n\n var temp = arr[i - 1]\n arr[i - 1] = arr[j]\n arr[j] = temp\n\n j = arr.size - 1\n while (i < j) {\n temp = arr[i]\n arr[i] = arr[j]\n arr[j] = temp\n i++\n j--\n }\n\n return true\n }\n\n val N = readLine()!!.toInt()\n\n val PN = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n val QN = readLine()!!.split(\" \").map(String::toInt).toIntArray()\n\n val array = (1..N).toList().toIntArray()\n\n var index = 1\n var a = 0\n var b = 0\n do {\n if (PN.joinToString(\"\") == array.joinToString(\"\")) {\n a = index\n }\n if (QN.joinToString(\"\") == array.joinToString(\"\")) {\n b = index\n }\n index++\n\n } while (nextPermutation(array))\n\n println(Math.abs(a - b))\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "sample_input": "3\n1 3 2\n3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02813", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1166, "cpu_time_ms": 389, "memory_kb": 53080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s792512723", "group_id": "codeNet:p02813", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val P = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n val Q = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n val score1 = calc(P, N)\n// val score2 = calc(Q, N)\n// println(Math.abs(score1 - score2))\n}\n\nfun calc(a: MutableList, N: Int): Int {\n var score = 1\n// for (i in 0 until N) {\n// score += (a[i] - 1) * fact(N - i - 1)\n// for (j in i+1 until N) {\n// if (a[i] < a[j]) a[j]--\n// }\n// }\n return score\n}", "language": "Kotlin", "metadata": {"date": 1578716948, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02813/input.txt", "sample_output_relpath": "derived/input_output/data/p02813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02813/Kotlin/s792512723.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s792512723", "user_id": "u860789370"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val P = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n val Q = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n val score1 = calc(P, N)\n// val score2 = calc(Q, N)\n// println(Math.abs(score1 - score2))\n}\n\nfun calc(a: MutableList, N: Int): Int {\n var score = 1\n// for (i in 0 until N) {\n// score += (a[i] - 1) * fact(N - i - 1)\n// for (j in i+1 until N) {\n// if (a[i] < a[j]) a[j]--\n// }\n// }\n return score\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "sample_input": "3\n1 3 2\n3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02813", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 560, "cpu_time_ms": 256, "memory_kb": 36084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s417249222", "group_id": "codeNet:p02814", "input_text": "tailrec fun gcd(a:Long,b:Long):Long = if(b==0L) a else gcd(b,a%b)\nfun lcm(a:Long,b:Long) = a*b/gcd(b,a%b)\n\nfun main(args:Array) {\n\tabc000X()\n}\n\nfun abc000X() {\n\tval (n,m) = readLine()!!.split(\" \").map {it.toInt()}\n\tval a = readLine()!!.split(\" \").map {it.toLong()/2}\n\n\tval t = a.fold(1L) {i,j-> if(i>m) 0 else lcm(i,j)}\n\tprintln(if(t==0L) 0 else (m+t)/t/2)\n}\n", "language": "Kotlin", "metadata": {"date": 1588880111, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/Kotlin/s417249222.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s417249222", "user_id": "u059234158"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "tailrec fun gcd(a:Long,b:Long):Long = if(b==0L) a else gcd(b,a%b)\nfun lcm(a:Long,b:Long) = a*b/gcd(b,a%b)\n\nfun main(args:Array) {\n\tabc000X()\n}\n\nfun abc000X() {\n\tval (n,m) = readLine()!!.split(\" \").map {it.toInt()}\n\tval a = readLine()!!.split(\" \").map {it.toLong()/2}\n\n\tval t = a.fold(1L) {i,j-> if(i>m) 0 else lcm(i,j)}\n\tprintln(if(t==0L) 0 else (m+t)/t/2)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 367, "cpu_time_ms": 558, "memory_kb": 71800}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s060669101", "group_id": "codeNet:p02814", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (n, m) = readListOfLong()\n\n val aList = readListOfLong().distinct().sorted()\n val lcm_ = aList.reduce { acc, v -> lcm(acc, v) }\n val numsDiv2 = aList.map {\n var k = it\n var cnt = 0\n while(k % 2L == 0L) {\n k /= 2L\n cnt++\n }\n cnt\n }.distinct()\n\n val cnt = if(numsDiv2.size > 1) 0L else {\n if(lcm_ > 2L * m) 0L \n else 1L + (m - lcm_ / 2L) / lcm_\n }\n \n println(cnt)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1578717386, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/Kotlin/s060669101.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s060669101", "user_id": "u026686258"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (n, m) = readListOfLong()\n\n val aList = readListOfLong().distinct().sorted()\n val lcm_ = aList.reduce { acc, v -> lcm(acc, v) }\n val numsDiv2 = aList.map {\n var k = it\n var cnt = 0\n while(k % 2L == 0L) {\n k /= 2L\n cnt++\n }\n cnt\n }.distinct()\n\n val cnt = if(numsDiv2.size > 1) 0L else {\n if(lcm_ > 2L * m) 0L \n else 1L + (m - lcm_ / 2L) / lcm_\n }\n \n println(cnt)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4099, "cpu_time_ms": 558, "memory_kb": 74256}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s345725995", "group_id": "codeNet:p02819", "input_text": "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\n\nfun mySqrt(x: Int): Int {\n var low: Long = 0\n var high = x.toLong()\n var mid = x.toLong()\n while (low <= high) {\n mid = low + (high - low) / 2\n if (mid * mid == x.toLong()) return mid.toInt() else if (mid * mid < x) low = mid + 1 else high = mid - 1\n }\n return if (mid * mid > x) mid.toInt() - 1 else mid.toInt()\n}\n\nfun isPrime(n: Int): Boolean {\n if (n > 2 && n % 2 == 0) return false\n var i = 3\n while (i <= mySqrt(n)) {\n if (n % i == 0) {\n return false\n }\n i += 2;\n }\n return n > 1\n}\n\nfun main() {\n\n var n = readInt()\n while (!isPrime(n)) {\n n++\n }\n println(n)\n\n}\n\n", "language": "Kotlin", "metadata": {"date": 1590809141, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02819/input.txt", "sample_output_relpath": "derived/input_output/data/p02819/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02819/Kotlin/s345725995.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s345725995", "user_id": "u992675902"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "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\n\nfun mySqrt(x: Int): Int {\n var low: Long = 0\n var high = x.toLong()\n var mid = x.toLong()\n while (low <= high) {\n mid = low + (high - low) / 2\n if (mid * mid == x.toLong()) return mid.toInt() else if (mid * mid < x) low = mid + 1 else high = mid - 1\n }\n return if (mid * mid > x) mid.toInt() - 1 else mid.toInt()\n}\n\nfun isPrime(n: Int): Boolean {\n if (n > 2 && n % 2 == 0) return false\n var i = 3\n while (i <= mySqrt(n)) {\n if (n % i == 0) {\n return false\n }\n i += 2;\n }\n return n > 1\n}\n\nfun main() {\n\n var n = readInt()\n while (!isPrime(n)) {\n n++\n }\n println(n)\n\n}\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 915, "cpu_time_ms": 162, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s245793070", "group_id": "codeNet:p02819", "input_text": "fun main(args: Array) {\n val input1 = readLine()!!.split(\" \")\n var takahashiCookieCount = input1[0].toLong()\n var aokiCookieCount = input1[1].toLong()\n val operationCount = input1[2].toLong()\n\n val aokiCookieCount2 = aokiCookieCount - (operationCount - takahashiCookieCount)\n\n println(\"0 $aokiCookieCount2\")\n}\n", "language": "Kotlin", "metadata": {"date": 1582324299, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02819/input.txt", "sample_output_relpath": "derived/input_output/data/p02819/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02819/Kotlin/s245793070.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s245793070", "user_id": "u098714032"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "fun main(args: Array) {\n val input1 = readLine()!!.split(\" \")\n var takahashiCookieCount = input1[0].toLong()\n var aokiCookieCount = input1[1].toLong()\n val operationCount = input1[2].toLong()\n\n val aokiCookieCount2 = aokiCookieCount - (operationCount - takahashiCookieCount)\n\n println(\"0 $aokiCookieCount2\")\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 336, "cpu_time_ms": 256, "memory_kb": 37780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s223120062", "group_id": "codeNet:p02820", "input_text": "import java.io.PrintWriter\n\n@JvmField val _writer = PrintWriter(System.out, false)\nfun main(args: Array) { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val (s, p, r) = readLine()!!.split(' ').map { it.toInt() }\n val t = readLine()!!\n val l = Math.ceil(n.toDouble()/k.toDouble()).toInt()\n val m = Math.ceil(n.toDouble()/l.toDouble()).toInt()\n val arr = Array(m) {CharArray(l)}\n var ans = 0L\n repeat(m) {i ->\n var prev = '0'\n repeat(l) { j ->\n if (i + j*k < n) {\n val now = t[i + j * k]\n arr[i][j] = now\n if (now != prev) {\n when (now) {\n 'r' -> ans += r\n 's' -> ans += s\n 'p' -> ans += p\n }\n prev = now\n } else {\n prev = '0'\n }\n }\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1587875544, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02820.html", "problem_id": "p02820", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02820/input.txt", "sample_output_relpath": "derived/input_output/data/p02820/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02820/Kotlin/s223120062.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s223120062", "user_id": "u288435405"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "import java.io.PrintWriter\n\n@JvmField val _writer = PrintWriter(System.out, false)\nfun main(args: Array) { _writer.solve(); _writer.flush() }\nfun PrintWriter.solve() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val (s, p, r) = readLine()!!.split(' ').map { it.toInt() }\n val t = readLine()!!\n val l = Math.ceil(n.toDouble()/k.toDouble()).toInt()\n val m = Math.ceil(n.toDouble()/l.toDouble()).toInt()\n val arr = Array(m) {CharArray(l)}\n var ans = 0L\n repeat(m) {i ->\n var prev = '0'\n repeat(l) { j ->\n if (i + j*k < n) {\n val now = t[i + j * k]\n arr[i][j] = now\n if (now != prev) {\n when (now) {\n 'r' -> ans += r\n 's' -> ans += s\n 'p' -> ans += p\n }\n prev = now\n } else {\n prev = '0'\n }\n }\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "sample_input": "5 2\n8 7 6\nrsrpr\n"}, "reference_outputs": ["27\n"], "source_document_id": "p02820", "source_text": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1027, "cpu_time_ms": 295, "memory_kb": 41272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s485613761", "group_id": "codeNet:p02821", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (N, M) = readInputLine().split(\" \").map { it.toLong() }\n val AArr = readInputLine().split(\" \").map { it.toLong() }.sortedDescending().toLongArray()\n val Amax = AArr[0]\n\n // パワーがi以上の人数\n // カウント人数配列のインデックスA_kの値を加算後、上から累積和を取ることで求められる\n val powCnt = LongArray(Amax.toInt() * 2 + 1)\n\n for (A in AArr) {\n powCnt[A.toInt()]++\n }\n\n for (i in Amax.toInt() - 1 downTo 0) {\n powCnt[i] += powCnt[i + 1]\n }\n\n // M以上の回数増やせる幸福度X最大値の二分探索\n // 左手のパワーを固定すれば、先に求めた配列からO(1)で求められ、左手がN人いるため1回あたりO(N)で求められる\n var l = 0L\n var r = Amax * 2L + 1L\n\n while (r - l > 1L) {\n val m = (l + r) / 2L\n val cnt = AArr.fold(0L) { acc, A -> acc + powCnt[Math.max(0L, m - A).toInt()] }\n if (cnt >= M) {\n l = m\n } else {\n r = m\n }\n }\n\n // 答えを求める\n // 幸福度Xを増やせるパターンがMより多い可能性があるため、X + 1増やせるパターンの個数を求め、M - その個数分だけ最後に足すことにする\n var already = 0L\n var ans = 0L\n\n // Aの降順累積和\n // 幸福度X + 1での総和を求める際、先のpowCntをインデックスとすれば各左手について総和が求められる\n // ただし、カウントは0を取る場合があるため、1から使用することにする\n val sumArr = LongArray(N.toInt() + 1)\n for (i in 0 until N.toInt()) {\n sumArr[i + 1] = sumArr[i] + AArr[i]\n }\n\n for (A in AArr) {\n val cnt = powCnt[Math.max(0L, r - A).toInt()]\n ans += A * cnt + sumArr[cnt.toInt()]\n already += cnt\n }\n\n ans += l * (M - already)\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1577912992, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02821.html", "problem_id": "p02821", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02821/input.txt", "sample_output_relpath": "derived/input_output/data/p02821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02821/Kotlin/s485613761.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s485613761", "user_id": "u505558493"}, "prompt_components": {"gold_output": "202\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (N, M) = readInputLine().split(\" \").map { it.toLong() }\n val AArr = readInputLine().split(\" \").map { it.toLong() }.sortedDescending().toLongArray()\n val Amax = AArr[0]\n\n // パワーがi以上の人数\n // カウント人数配列のインデックスA_kの値を加算後、上から累積和を取ることで求められる\n val powCnt = LongArray(Amax.toInt() * 2 + 1)\n\n for (A in AArr) {\n powCnt[A.toInt()]++\n }\n\n for (i in Amax.toInt() - 1 downTo 0) {\n powCnt[i] += powCnt[i + 1]\n }\n\n // M以上の回数増やせる幸福度X最大値の二分探索\n // 左手のパワーを固定すれば、先に求めた配列からO(1)で求められ、左手がN人いるため1回あたりO(N)で求められる\n var l = 0L\n var r = Amax * 2L + 1L\n\n while (r - l > 1L) {\n val m = (l + r) / 2L\n val cnt = AArr.fold(0L) { acc, A -> acc + powCnt[Math.max(0L, m - A).toInt()] }\n if (cnt >= M) {\n l = m\n } else {\n r = m\n }\n }\n\n // 答えを求める\n // 幸福度Xを増やせるパターンがMより多い可能性があるため、X + 1増やせるパターンの個数を求め、M - その個数分だけ最後に足すことにする\n var already = 0L\n var ans = 0L\n\n // Aの降順累積和\n // 幸福度X + 1での総和を求める際、先のpowCntをインデックスとすれば各左手について総和が求められる\n // ただし、カウントは0を取る場合があるため、1から使用することにする\n val sumArr = LongArray(N.toInt() + 1)\n for (i in 0 until N.toInt()) {\n sumArr[i + 1] = sumArr[i] + AArr[i]\n }\n\n for (A in AArr) {\n val cnt = powCnt[Math.max(0L, r - A).toInt()]\n ans += A * cnt + sumArr[cnt.toInt()]\n already += cnt\n }\n\n ans += l * (M - already)\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "sample_input": "5 3\n10 14 19 34 33\n"}, "reference_outputs": ["202\n"], "source_document_id": "p02821", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2011, "cpu_time_ms": 737, "memory_kb": 65876}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s194710065", "group_id": "codeNet:p02823", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n\n val ba = b - a\n if ((ba) % 2L == 0L) {\n println(ba / 2L)\n return\n }\n\n\n val len = Math.min(b - 1, n - a)\n println(len)\n}", "language": "Kotlin", "metadata": {"date": 1591564621, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02823/input.txt", "sample_output_relpath": "derived/input_output/data/p02823/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02823/Kotlin/s194710065.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s194710065", "user_id": "u323522006"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n\n val ba = b - a\n if ((ba) % 2L == 0L) {\n println(ba / 2L)\n return\n }\n\n\n val len = Math.min(b - 1, n - a)\n println(len)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 199, "memory_kb": 31272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s263121827", "group_id": "codeNet:p02823", "input_text": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toLong)\n\n if ((b - a) % 2 == 0L) {\n println((b - a) / 2)\n return\n }\n val left = a+(b-a-1)/2\n val right = (n-b+1)+(n-a-(n-b+1))/2\n println(Math.min(left,right))\n}", "language": "Kotlin", "metadata": {"date": 1577585441, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02823/input.txt", "sample_output_relpath": "derived/input_output/data/p02823/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02823/Kotlin/s263121827.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s263121827", "user_id": "u099066216"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toLong)\n\n if ((b - a) % 2 == 0L) {\n println((b - a) / 2)\n return\n }\n val left = a+(b-a-1)/2\n val right = (n-b+1)+(n-a-(n-b+1))/2\n println(Math.min(left,right))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 278, "cpu_time_ms": 243, "memory_kb": 38136}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s416882582", "group_id": "codeNet:p02823", "input_text": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toLong)\n\n if ((b - a) % 2 == 0L) {\n println((b - a) / 2)\n return\n }\n val left = a+(b-a-1)/2\n val right = (n-b+1)+(n-a+(n-b+1))/2\n println(Math.min(left,right))\n}", "language": "Kotlin", "metadata": {"date": 1577585277, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02823/input.txt", "sample_output_relpath": "derived/input_output/data/p02823/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02823/Kotlin/s416882582.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s416882582", "user_id": "u099066216"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, a, b) = readLine()!!.split(' ').map(String::toLong)\n\n if ((b - a) % 2 == 0L) {\n println((b - a) / 2)\n return\n }\n val left = a+(b-a-1)/2\n val right = (n-b+1)+(n-a+(n-b+1))/2\n println(Math.min(left,right))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 278, "cpu_time_ms": 237, "memory_kb": 38148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s621798244", "group_id": "codeNet:p02824", "input_text": "fun main(args : Array) {\n val (n, m, v, p) = readLine()!!.split(\" \").map { it.toInt() }\n val aa = readLine()!!.split(\" \").map { it.toInt() }.sortedDescending()\n\n var cnt = 0\n var min = -1\n var minSum = 0L\n var lastIndex = 0\n var sameCnt = 1\n repeat(n) {\n if (it < p) {\n cnt++\n if (aa[it] != min) {\n min = aa[it]\n minSum = min.toLong()\n lastIndex = it\n sameCnt = 1\n } else {\n minSum += min\n sameCnt++\n }\n return@repeat\n }\n\n if (min == aa[it]) {\n cnt++\n sameCnt++\n minSum += min\n return@repeat\n }\n\n val max = aa[it] + m\n val countUpSafely = (n - it) + lastIndex\n if (min <= max && v <= countUpSafely) {\n cnt++\n minSum += aa[it]\n return@repeat\n }\n\n val vNeeded = v - countUpSafely\n val voteSum = minSum + (m.toLong() * vNeeded.toLong())\n val itemCnt = it - lastIndex\n if ((voteSum.toFloat() / itemCnt.toFloat()) <= max.toFloat()) cnt++\n minSum += aa[it]\n }\n\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1577593018, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02824/input.txt", "sample_output_relpath": "derived/input_output/data/p02824/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02824/Kotlin/s621798244.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s621798244", "user_id": "u262403099"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, m, v, p) = readLine()!!.split(\" \").map { it.toInt() }\n val aa = readLine()!!.split(\" \").map { it.toInt() }.sortedDescending()\n\n var cnt = 0\n var min = -1\n var minSum = 0L\n var lastIndex = 0\n var sameCnt = 1\n repeat(n) {\n if (it < p) {\n cnt++\n if (aa[it] != min) {\n min = aa[it]\n minSum = min.toLong()\n lastIndex = it\n sameCnt = 1\n } else {\n minSum += min\n sameCnt++\n }\n return@repeat\n }\n\n if (min == aa[it]) {\n cnt++\n sameCnt++\n minSum += min\n return@repeat\n }\n\n val max = aa[it] + m\n val countUpSafely = (n - it) + lastIndex\n if (min <= max && v <= countUpSafely) {\n cnt++\n minSum += aa[it]\n return@repeat\n }\n\n val vNeeded = v - countUpSafely\n val voteSum = minSum + (m.toLong() * vNeeded.toLong())\n val itemCnt = it - lastIndex\n if ((voteSum.toFloat() / itemCnt.toFloat()) <= max.toFloat()) cnt++\n minSum += aa[it]\n }\n\n println(cnt)\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "sample_input": "6 1 2 2\n2 1 1 3 0 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02824", "source_text": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1221, "cpu_time_ms": 684, "memory_kb": 53632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s570249188", "group_id": "codeNet:p02831", "input_text": "fun main(args: Array){\n val (a,b) = readLine()!!.split(' ').map{it.toLong()}\n println(a/gcd(a,b)*b)\n}\n\nfun gcd(a: Long, b: Long) : Long{\n when(b){\n \t0L -> return a\n else -> return gcd(b, a%b)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1577160799, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02831/input.txt", "sample_output_relpath": "derived/input_output/data/p02831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02831/Kotlin/s570249188.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s570249188", "user_id": "u734519000"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array){\n val (a,b) = readLine()!!.split(' ').map{it.toLong()}\n println(a/gcd(a,b)*b)\n}\n\nfun gcd(a: Long, b: Long) : Long{\n when(b){\n \t0L -> return a\n else -> return gcd(b, a%b)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 229, "memory_kb": 36412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s061442206", "group_id": "codeNet:p02831", "input_text": "fun main(args :Array) {\n val (a, b) = readLongList()\n (a / gcd(a, b) * b).let { println(it) }\n}\n\nfun gcd(a: Long, b: Long): Long {\n var c = a\n var d = b\n while (d > 0) {\n val e = c % d\n c = d\n d = e\n }\n\n return c\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1577079038, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02831/input.txt", "sample_output_relpath": "derived/input_output/data/p02831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02831/Kotlin/s061442206.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s061442206", "user_id": "u784448849"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args :Array) {\n val (a, b) = readLongList()\n (a / gcd(a, b) * b).let { println(it) }\n}\n\nfun gcd(a: Long, b: Long): Long {\n var c = a\n var d = b\n while (d > 0) {\n val e = c % d\n c = d\n d = e\n }\n\n return c\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 233, "memory_kb": 37816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s445877986", "group_id": "codeNet:p02833", "input_text": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n if (n % 2L == 1L) {\n println(\"0\")\n } else {\n var d = 5L\n var total = 0L\n while (d <= n) {\n total += (n / d) / 2\n d *= 5L\n }\n println(total.toString())\n }\n}", "language": "Kotlin", "metadata": {"date": 1589749529, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02833/input.txt", "sample_output_relpath": "derived/input_output/data/p02833/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02833/Kotlin/s445877986.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445877986", "user_id": "u979429407"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n if (n % 2L == 1L) {\n println(\"0\")\n } else {\n var d = 5L\n var total = 0L\n while (d <= n) {\n total += (n / d) / 2\n d *= 5L\n }\n println(total.toString())\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "sample_input": "12\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02833", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 304, "cpu_time_ms": 202, "memory_kb": 31588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s611190047", "group_id": "codeNet:p02833", "input_text": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n\n if (n % 2L == 1L) {\n println(\"0\")\n } else {\n var d = 10L\n var total = 0L\n do {\n total += Math.floor(n.toDouble() / d.toDouble()).toLong()\n d *= 5L\n } while (d <= n)\n println(total.toString())\n }\n}", "language": "Kotlin", "metadata": {"date": 1589745735, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02833/input.txt", "sample_output_relpath": "derived/input_output/data/p02833/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02833/Kotlin/s611190047.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s611190047", "user_id": "u979429407"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n\n if (n % 2L == 1L) {\n println(\"0\")\n } else {\n var d = 10L\n var total = 0L\n do {\n total += Math.floor(n.toDouble() / d.toDouble()).toLong()\n d *= 5L\n } while (d <= n)\n println(total.toString())\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "sample_input": "12\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02833", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 346, "cpu_time_ms": 215, "memory_kb": 33608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s079535161", "group_id": "codeNet:p02834", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (n, taka, ao) = readLine()!!.split(' ').map(String::toInt)\n\n val branch = Array(n) { mutableSetOf() }\n (1 until n).forEach {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n branch[a].add(b)\n branch[b].add(a)\n }\n val takaMinCost = LongArray(n + 1) { Long.MAX_VALUE / 2 }\n val aoMinCost = LongArray(n + 1) { Long.MAX_VALUE / 2 }\n\n takaMinCost[taka]=0\n aoMinCost[ao]=0\n val queue = ArrayDeque().apply { addFirst(taka) }\n while (queue.isNotEmpty()) {\n val cur = queue.pollLast()!!\n for (to in branch[cur]) {\n if (takaMinCost[to] > takaMinCost[cur] + 1) {\n takaMinCost[to] = takaMinCost[cur] + 1\n queue.addFirst(to)\n }\n }\n }\n queue.add(ao)\n while (queue.isNotEmpty()) {\n val cur = queue.pollLast()!!\n for (to in branch[cur]) {\n if (aoMinCost[to] > aoMinCost[cur] + 1) {\n aoMinCost[to] = aoMinCost[cur] + 1\n queue.addFirst(to)\n }\n }\n }\n\n val aoTakaDist = aoMinCost[taka]\n val cost = aoMinCost[(1..n).filter { aoMinCost[it] > takaMinCost[it] }.maxBy { aoMinCost[it] }!!]\n println(cost - 1)\n}", "language": "Kotlin", "metadata": {"date": 1577070642, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02834.html", "problem_id": "p02834", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02834/input.txt", "sample_output_relpath": "derived/input_output/data/p02834/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02834/Kotlin/s079535161.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s079535161", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (n, taka, ao) = readLine()!!.split(' ').map(String::toInt)\n\n val branch = Array(n) { mutableSetOf() }\n (1 until n).forEach {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n branch[a].add(b)\n branch[b].add(a)\n }\n val takaMinCost = LongArray(n + 1) { Long.MAX_VALUE / 2 }\n val aoMinCost = LongArray(n + 1) { Long.MAX_VALUE / 2 }\n\n takaMinCost[taka]=0\n aoMinCost[ao]=0\n val queue = ArrayDeque().apply { addFirst(taka) }\n while (queue.isNotEmpty()) {\n val cur = queue.pollLast()!!\n for (to in branch[cur]) {\n if (takaMinCost[to] > takaMinCost[cur] + 1) {\n takaMinCost[to] = takaMinCost[cur] + 1\n queue.addFirst(to)\n }\n }\n }\n queue.add(ao)\n while (queue.isNotEmpty()) {\n val cur = queue.pollLast()!!\n for (to in branch[cur]) {\n if (aoMinCost[to] > aoMinCost[cur] + 1) {\n aoMinCost[to] = aoMinCost[cur] + 1\n queue.addFirst(to)\n }\n }\n }\n\n val aoTakaDist = aoMinCost[taka]\n val cost = aoMinCost[(1..n).filter { aoMinCost[it] > takaMinCost[it] }.maxBy { aoMinCost[it] }!!]\n println(cost - 1)\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.\n\nTakahashi is standing at Vertex u, and Aoki is standing at Vertex v.\n\nNow, they will play a game of tag as follows:\n\n1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vertex of his choice that is adjacent to his current vertex.\n\n2. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Aoki moves to a vertex of his choice that is adjacent to his current vertex.\n\n3. Go back to step 1.\n\nTakahashi performs his moves so that the game ends as late as possible, while Aoki performs his moves so that the game ends as early as possible.\n\nFind the number of moves Aoki will perform before the end of the game if both Takahashi and Aoki know each other's position and strategy.\n\nIt can be proved that the game is bound to end.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq u,v \\leq N\n\nu \\neq v\n\n1 \\leq A_i,B_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN u v\nA_1 B_1\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the number of moves Aoki will perform before the end of the game.\n\nSample Input 1\n\n5 4 1\n1 2\n2 3\n3 4\n3 5\n\nSample Output 1\n\n2\n\nIf both players play optimally, the game will progress as follows:\n\nTakahashi moves to Vertex 3.\n\nAoki moves to Vertex 2.\n\nTakahashi moves to Vertex 5.\n\nAoki moves to Vertex 3.\n\nTakahashi moves to Vertex 3.\n\nHere, Aoki performs two moves.\n\nNote that, in each move, it is prohibited to stay at the current vertex.\n\nSample Input 2\n\n5 4 5\n1 2\n1 3\n1 4\n1 5\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2 1 2\n1 2\n\nSample Output 3\n\n0\n\nSample Input 4\n\n9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n7 8\n8 9\n\nSample Output 4\n\n5", "sample_input": "5 4 1\n1 2\n2 3\n3 4\n3 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02834", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.\n\nTakahashi is standing at Vertex u, and Aoki is standing at Vertex v.\n\nNow, they will play a game of tag as follows:\n\n1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vertex of his choice that is adjacent to his current vertex.\n\n2. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Aoki moves to a vertex of his choice that is adjacent to his current vertex.\n\n3. Go back to step 1.\n\nTakahashi performs his moves so that the game ends as late as possible, while Aoki performs his moves so that the game ends as early as possible.\n\nFind the number of moves Aoki will perform before the end of the game if both Takahashi and Aoki know each other's position and strategy.\n\nIt can be proved that the game is bound to end.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq u,v \\leq N\n\nu \\neq v\n\n1 \\leq A_i,B_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN u v\nA_1 B_1\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the number of moves Aoki will perform before the end of the game.\n\nSample Input 1\n\n5 4 1\n1 2\n2 3\n3 4\n3 5\n\nSample Output 1\n\n2\n\nIf both players play optimally, the game will progress as follows:\n\nTakahashi moves to Vertex 3.\n\nAoki moves to Vertex 2.\n\nTakahashi moves to Vertex 5.\n\nAoki moves to Vertex 3.\n\nTakahashi moves to Vertex 3.\n\nHere, Aoki performs two moves.\n\nNote that, in each move, it is prohibited to stay at the current vertex.\n\nSample Input 2\n\n5 4 5\n1 2\n1 3\n1 4\n1 5\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2 1 2\n1 2\n\nSample Output 3\n\n0\n\nSample Input 4\n\n9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n7 8\n8 9\n\nSample Output 4\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1279, "cpu_time_ms": 871, "memory_kb": 93864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s660394569", "group_id": "codeNet:p02835", "input_text": "fun main(args: Array) {\n val (a1, a2, a3) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n if(a1 + a2 + a3 > 21){\n println(\"bust\")\n }\n else{\n println(\"win\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1587269662, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/Kotlin/s660394569.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s660394569", "user_id": "u979429407"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "fun main(args: Array) {\n val (a1, a2, a3) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n if(a1 + a2 + a3 > 21){\n println(\"bust\")\n }\n else{\n println(\"win\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 206, "cpu_time_ms": 236, "memory_kb": 35948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s496563273", "group_id": "codeNet:p02837", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int, xy: Array>>) {\n fun isConsistent(flag: List): Boolean {\n // flag=1の人たちの証言が整合するか\n for (honest in flag.withIndex().filter{ it.value == 1 }.map{ it.index }) {\n for (statement in xy[honest]) {\n if (flag[statement.first - 1] != statement.second) return false\n }\n }\n return true\n }\n // println(xy.toList())\n // bit all search\n var ans = 0\n for (i in 0 until (1 shl N)) {\n val flags = (0 until N).map { (i shr it) and 1 }\n if (flags.sum() <= ans) continue\n if (isConsistent(flags)) { ans = flags.sum() }\n }\n println(ans)\n return\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val xy = Array(N) { mutableListOf>() }\n for (i in 0 until N) {\n val A = sc.next().toInt()\n repeat(A){\n val x = sc.next().toInt()\n val y = sc.next().toInt()\n xy[i].add(x to y)\n }\n }\n solve(N, xy)\n}\n", "language": "Kotlin", "metadata": {"date": 1575926054, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02837.html", "problem_id": "p02837", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02837/input.txt", "sample_output_relpath": "derived/input_output/data/p02837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02837/Kotlin/s496563273.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496563273", "user_id": "u329232967"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int, xy: Array>>) {\n fun isConsistent(flag: List): Boolean {\n // flag=1の人たちの証言が整合するか\n for (honest in flag.withIndex().filter{ it.value == 1 }.map{ it.index }) {\n for (statement in xy[honest]) {\n if (flag[statement.first - 1] != statement.second) return false\n }\n }\n return true\n }\n // println(xy.toList())\n // bit all search\n var ans = 0\n for (i in 0 until (1 shl N)) {\n val flags = (0 until N).map { (i shr it) and 1 }\n if (flags.sum() <= ans) continue\n if (isConsistent(flags)) { ans = flags.sum() }\n }\n println(ans)\n return\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val xy = Array(N) { mutableListOf>() }\n for (i in 0 until N) {\n val A = sc.next().toInt()\n repeat(A){\n val x = sc.next().toInt()\n val y = sc.next().toInt()\n xy[i].add(x to y)\n }\n }\n solve(N, xy)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "sample_input": "3\n1\n2 1\n1\n1 1\n1\n2 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02837", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1595, "cpu_time_ms": 649, "memory_kb": 51460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163151596", "group_id": "codeNet:p02838", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val result = solve(Scanner(System.`in`))\n if (result.isNotEmpty()) println(result)\n}\n\nfun solve(`in`: String) = solve(Scanner(`in`))\n\nfun solve(sc: Scanner): String {\n val N = sc.nextInt()\n val A = (1..N).map { sc.nextLong() }\n val nA = A.count()\n val MOD = 1000000007L\n\n var ans: Long = 0L\n for (b in 0..60) {\n val bn = 1L shl b\n val n0 = A.count { it and bn == 0L }.toLong()\n ans += (bn * (n0 * (nA - n0))) % MOD\n ans %= MOD\n }\n\n return ans.toString()\n}\n", "language": "Kotlin", "metadata": {"date": 1584053224, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02838/input.txt", "sample_output_relpath": "derived/input_output/data/p02838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02838/Kotlin/s163151596.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s163151596", "user_id": "u297767059"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val result = solve(Scanner(System.`in`))\n if (result.isNotEmpty()) println(result)\n}\n\nfun solve(`in`: String) = solve(Scanner(`in`))\n\nfun solve(sc: Scanner): String {\n val N = sc.nextInt()\n val A = (1..N).map { sc.nextLong() }\n val nA = A.count()\n val MOD = 1000000007L\n\n var ans: Long = 0L\n for (b in 0..60) {\n val bn = 1L shl b\n val n0 = A.count { it and bn == 0L }.toLong()\n ans += (bn * (n0 * (nA - n0))) % MOD\n ans %= MOD\n }\n\n return ans.toString()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02838", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 567, "cpu_time_ms": 959, "memory_kb": 117180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s828899370", "group_id": "codeNet:p02838", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val result = solve(Scanner(System.`in`))\n if (result.isNotEmpty()) println(result)\n}\n\nfun solve(`in`: String) = solve(Scanner(`in`))\n\nfun solve(sc: Scanner): String {\n val N = sc.nextInt()\n val A = (1..N).map { sc.nextLong() }\n val nA = A.count()\n val MOD = 1000000007\n\n var ans: Long = 0L\n for (b in 0..61) {\n val bn = 1L shl b\n val n0 = A.count { it and bn == 0L }\n ans += bn * (n0 * (nA - n0))\n ans %= MOD\n }\n\n return ans.toString()\n}\n", "language": "Kotlin", "metadata": {"date": 1584052291, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02838/input.txt", "sample_output_relpath": "derived/input_output/data/p02838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02838/Kotlin/s828899370.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s828899370", "user_id": "u297767059"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val result = solve(Scanner(System.`in`))\n if (result.isNotEmpty()) println(result)\n}\n\nfun solve(`in`: String) = solve(Scanner(`in`))\n\nfun solve(sc: Scanner): String {\n val N = sc.nextInt()\n val A = (1..N).map { sc.nextLong() }\n val nA = A.count()\n val MOD = 1000000007\n\n var ans: Long = 0L\n for (b in 0..61) {\n val bn = 1L shl b\n val n0 = A.count { it and bn == 0L }\n ans += bn * (n0 * (nA - n0))\n ans %= MOD\n }\n\n return ans.toString()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02838", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 549, "cpu_time_ms": 958, "memory_kb": 114804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s725902400", "group_id": "codeNet:p02841", "input_text": "fun main(args: Array) {\n val (m1, d1) = readLine()!!.split(\" \").map { it.toInt() }\n val (m2, d2) = readLine()!!.split(\" \").map { it.toInt() }\n if (m1 == m2) {\n println(0)\n } else {\n println(1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1575252185, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02841.html", "problem_id": "p02841", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02841/input.txt", "sample_output_relpath": "derived/input_output/data/p02841/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02841/Kotlin/s725902400.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725902400", "user_id": "u388719350"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "fun main(args: Array) {\n val (m1, d1) = readLine()!!.split(\" \").map { it.toInt() }\n val (m2, d2) = readLine()!!.split(\" \").map { it.toInt() }\n if (m1 == m2) {\n println(0)\n } else {\n println(1)\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "sample_input": "11 16\n11 17\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02841", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 234, "cpu_time_ms": 271, "memory_kb": 36032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s280456074", "group_id": "codeNet:p02842", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n println(b(n))\n}\n\nprivate fun b(n: Int): String {\n var ans = -1\n for (i in 1..50000) {\n if (i * 108 / 100 == n) {\n ans = i\n break;\n }\n }\n if (ans == -1) return \":(\"\n\n return ans.toString()\n}\n", "language": "Kotlin", "metadata": {"date": 1590116088, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/Kotlin/s280456074.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s280456074", "user_id": "u323522006"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n println(b(n))\n}\n\nprivate fun b(n: Int): String {\n var ans = -1\n for (i in 1..50000) {\n if (i * 108 / 100 == n) {\n ans = i\n break;\n }\n }\n if (ans == -1) return \":(\"\n\n return ans.toString()\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 187, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s103438625", "group_id": "codeNet:p02842", "input_text": "fun main(args: Array) {\n val n1 = readLine()!!.toInt()\n solve(n1)\n}\n\nfun solve(n1: Int){\n // (ans / 1.08).floor() = n1\n val moto = (n1 / 1.08).toInt()\n\n val kouho = Math.floor(moto * 1.08)\n\n val answer = if( kouho.toInt() == n1 ) n1.toString() else \":(\"\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1575271597, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/Kotlin/s103438625.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s103438625", "user_id": "u509162259"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "fun main(args: Array) {\n val n1 = readLine()!!.toInt()\n solve(n1)\n}\n\nfun solve(n1: Int){\n // (ans / 1.08).floor() = n1\n val moto = (n1 / 1.08).toInt()\n\n val kouho = Math.floor(moto * 1.08)\n\n val answer = if( kouho.toInt() == n1 ) n1.toString() else \":(\"\n println(answer)\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 302, "cpu_time_ms": 202, "memory_kb": 31660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s577701447", "group_id": "codeNet:p02842", "input_text": "fun main(args: Array) {\n val (N) = readLine()!!.split(' ').map(String::toLong)\n val t = Math.floor(N / 1.08).toLong()\n for (i in -3..3) {\n if (Math.floor((t + i) * 1.08).toLong() == N) {\n println(t+i)\n return\n }\n }\n println(\":(\")\n}", "language": "Kotlin", "metadata": {"date": 1575252467, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/Kotlin/s577701447.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s577701447", "user_id": "u646103151"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "fun main(args: Array) {\n val (N) = readLine()!!.split(' ').map(String::toLong)\n val t = Math.floor(N / 1.08).toLong()\n for (i in -3..3) {\n if (Math.floor((t + i) * 1.08).toLong() == N) {\n println(t+i)\n return\n }\n }\n println(\":(\")\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 290, "cpu_time_ms": 274, "memory_kb": 38236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s702397342", "group_id": "codeNet:p02843", "input_text": "fun main(args: Array) {\n val X = readInputLine().toInt()\n \n if (X < 100) {\n println(0)\n return\n }\n\n if (X % 100 <= X / 100 * 5) {\n println(1)\n } else {\n println(0)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1575252745, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02843.html", "problem_id": "p02843", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02843/input.txt", "sample_output_relpath": "derived/input_output/data/p02843/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02843/Kotlin/s702397342.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s702397342", "user_id": "u505558493"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val X = readInputLine().toInt()\n \n if (X < 100) {\n println(0)\n return\n }\n\n if (X % 100 <= X / 100 * 5) {\n println(1)\n } else {\n println(0)\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "sample_input": "615\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02843", "source_text": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 283, "cpu_time_ms": 244, "memory_kb": 33728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s023972965", "group_id": "codeNet:p02844", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nobject Solve {\n\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private val out = PrintWriter(System.out)\n\n fun solve() {\n\n val n = br.readLine()!!.toInt()\n val s = br.readLine()!!\n\n var ans = 0\n\n for (i in 0 until 1000) {\n val str = i.toString().padStart(3, '0')\n var cnt = 0\n for (c in s) {\n if (c == str[cnt]) {\n cnt++\n if (cnt == 3) {\n ans++\n break\n }\n }\n }\n }\n\n out.println(ans)\n out.flush()\n }\n}\n\nfun main(args: Array) {\n Solve.solve()\n}", "language": "Kotlin", "metadata": {"date": 1598836873, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/Kotlin/s023972965.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023972965", "user_id": "u756514276"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nobject Solve {\n\n private val br = BufferedReader(InputStreamReader(System.`in`))\n private val out = PrintWriter(System.out)\n\n fun solve() {\n\n val n = br.readLine()!!.toInt()\n val s = br.readLine()!!\n\n var ans = 0\n\n for (i in 0 until 1000) {\n val str = i.toString().padStart(3, '0')\n var cnt = 0\n for (c in s) {\n if (c == str[cnt]) {\n cnt++\n if (cnt == 3) {\n ans++\n break\n }\n }\n }\n }\n\n out.println(ans)\n out.flush()\n }\n}\n\nfun main(args: Array) {\n Solve.solve()\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 669, "cpu_time_ms": 184, "memory_kb": 36648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s233067880", "group_id": "codeNet:p02847", "input_text": "fun main(args: Array) {\n val S = readLine()!!\n val days = arrayOf(\"SUN\",\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\").reversed()\n for (i in days.indices) {\n if (days[i] == S) {\n println(i+1)\n break\n } \n }\n}", "language": "Kotlin", "metadata": {"date": 1574885519, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Kotlin/s233067880.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233067880", "user_id": "u808160425"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readLine()!!\n val days = arrayOf(\"SUN\",\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\").reversed()\n for (i in days.indices) {\n if (days[i] == S) {\n println(i+1)\n break\n } \n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 224, "memory_kb": 33912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s378017934", "group_id": "codeNet:p02847", "input_text": "fun main(args: Array) {\n var S = readString()\n println(\n when (S) {\n \"SUN\" -> 7\n \"MON\" -> 6\n \"TUE\" -> 5\n \"WED\" -> 4\n \"THU\" -> 3\n \"FRI\" -> 2\n \"SAT\" -> 1\n else -> 0\n }\n )\n\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\n\nfun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())", "language": "Kotlin", "metadata": {"date": 1574874965, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Kotlin/s378017934.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378017934", "user_id": "u043557308"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n var S = readString()\n println(\n when (S) {\n \"SUN\" -> 7\n \"MON\" -> 6\n \"TUE\" -> 5\n \"WED\" -> 4\n \"THU\" -> 3\n \"FRI\" -> 2\n \"SAT\" -> 1\n else -> 0\n }\n )\n\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)\n\nfun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 591, "cpu_time_ms": 206, "memory_kb": 31768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s253374877", "group_id": "codeNet:p02847", "input_text": "fun main(args: Array) {\n\n when (readLine()!!) {\n \"MON\" -> {\n println(1)\n }\n \"TUE\" -> {\n println(2)\n }\n \"WED\" -> {\n println(3)\n }\n \"THU\" -> {\n println(4)\n }\n \"FRI\" -> {\n println(5)\n }\n \"SAT\" -> {\n println(7)\n }\n \"SUN\" -> {\n println(7)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1574647475, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Kotlin/s253374877.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s253374877", "user_id": "u388719350"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n\n when (readLine()!!) {\n \"MON\" -> {\n println(1)\n }\n \"TUE\" -> {\n println(2)\n }\n \"WED\" -> {\n println(3)\n }\n \"THU\" -> {\n println(4)\n }\n \"FRI\" -> {\n println(5)\n }\n \"SAT\" -> {\n println(7)\n }\n \"SUN\" -> {\n println(7)\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 430, "cpu_time_ms": 203, "memory_kb": 31728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s076615298", "group_id": "codeNet:p02850", "input_text": "data class Edge(val to: Int, val id: Int)\nfun main(args: Array) {\n val N = nextInt()\n val G = Array>(N) { mutableListOf() }\n var ans = Array(N - 1) { 0 }\n repeat(N - 1) {\n val (a, b) = listOfInt(-1)\n G[a].add(Edge(b, it))\n G[b].add(Edge(a, it))\n }\n fun dfs(v: Int, c: Int = -1, p: Int = -1) {\n var k = 1\n repeat(G[v].count()) {\n val u = G[v][it].to\n val e = G[v][it].id\n if (u != p) {\n if (k == c) k += 1\n ans[e] = k++\n dfs(u, ans[e], v)\n }\n }\n }\n dfs(0)\n println(G.map { it.count() }.max())\n println(ans.joinToString(separator = \"\\n\"))\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun printErr(value: Any) = System.err.println(value)\n", "language": "Kotlin", "metadata": {"date": 1574740998, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02850/input.txt", "sample_output_relpath": "derived/input_output/data/p02850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02850/Kotlin/s076615298.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s076615298", "user_id": "u043150661"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "data class Edge(val to: Int, val id: Int)\nfun main(args: Array) {\n val N = nextInt()\n val G = Array>(N) { mutableListOf() }\n var ans = Array(N - 1) { 0 }\n repeat(N - 1) {\n val (a, b) = listOfInt(-1)\n G[a].add(Edge(b, it))\n G[b].add(Edge(a, it))\n }\n fun dfs(v: Int, c: Int = -1, p: Int = -1) {\n var k = 1\n repeat(G[v].count()) {\n val u = G[v][it].to\n val e = G[v][it].id\n if (u != p) {\n if (k == c) k += 1\n ans[e] = k++\n dfs(u, ans[e], v)\n }\n }\n }\n dfs(0)\n println(G.map { it.count() }.max())\n println(ans.joinToString(separator = \"\\n\"))\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\nfun printErr(value: Any) = System.err.println(value)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["2\n1\n2\n"], "source_document_id": "p02850", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 980, "cpu_time_ms": 958, "memory_kb": 78976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s709746214", "group_id": "codeNet:p02850", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val G = Array(N) { mutableListOf()}\n val colorMap = hashMapOf()\n val A = Array(N-1){0}\n val B = Array(N-1){0}\n for (d in 0..N-2) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n A[d] = a-1\n B[d] = b-1\n G[a-1].add(b-1)\n G[b-1].add(a-1)\n }\n\n val q = ArrayDeque()\n val visited = Array(N) {false}\n q.push(0)\n while (!q.isEmpty()) {\n val n = q.poll()\n if (visited[n]) continue\n visited[n] = true\n val es = G[n]\n val usedColors = mutableListOf()\n val uncoloredNeighbors = mutableListOf()\n for (neighbor in es) {\n val color = colorMap.get(n.toLong()*N + neighbor.toLong())\n if (color != null) {\n usedColors.add(color)\n } else {\n uncoloredNeighbors.add(neighbor)\n }\n }\n var newColor = 1\n for (neighbor in uncoloredNeighbors) {\n while (usedColors.contains(newColor)) {\n newColor++\n }\n colorMap[n.toLong() * N + neighbor.toLong()] = newColor\n colorMap[neighbor.toLong() * N + n.toLong()] = newColor\n usedColors.add(newColor)\n }\n for (next in uncoloredNeighbors) {\n q.add(next)\n }\n }\n println(colorMap.map{ x -> x.value}.max())\n for (d in 0..N-2) {\n val a = A[d]\n val b = B[d]\n println(colorMap[a.toLong() * N + b.toLong()])\n }\n}", "language": "Kotlin", "metadata": {"date": 1574654091, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02850/input.txt", "sample_output_relpath": "derived/input_output/data/p02850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02850/Kotlin/s709746214.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s709746214", "user_id": "u646103151"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val G = Array(N) { mutableListOf()}\n val colorMap = hashMapOf()\n val A = Array(N-1){0}\n val B = Array(N-1){0}\n for (d in 0..N-2) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n A[d] = a-1\n B[d] = b-1\n G[a-1].add(b-1)\n G[b-1].add(a-1)\n }\n\n val q = ArrayDeque()\n val visited = Array(N) {false}\n q.push(0)\n while (!q.isEmpty()) {\n val n = q.poll()\n if (visited[n]) continue\n visited[n] = true\n val es = G[n]\n val usedColors = mutableListOf()\n val uncoloredNeighbors = mutableListOf()\n for (neighbor in es) {\n val color = colorMap.get(n.toLong()*N + neighbor.toLong())\n if (color != null) {\n usedColors.add(color)\n } else {\n uncoloredNeighbors.add(neighbor)\n }\n }\n var newColor = 1\n for (neighbor in uncoloredNeighbors) {\n while (usedColors.contains(newColor)) {\n newColor++\n }\n colorMap[n.toLong() * N + neighbor.toLong()] = newColor\n colorMap[neighbor.toLong() * N + n.toLong()] = newColor\n usedColors.add(newColor)\n }\n for (next in uncoloredNeighbors) {\n q.add(next)\n }\n }\n println(colorMap.map{ x -> x.value}.max())\n for (d in 0..N-2) {\n val a = A[d]\n val b = B[d]\n println(colorMap[a.toLong() * N + b.toLong()])\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["2\n1\n2\n"], "source_document_id": "p02850", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1590, "cpu_time_ms": 2111, "memory_kb": 115084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s767027529", "group_id": "codeNet:p02850", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n val graph = Array(n) {\n mutableListOf()\n }\n val colorMap = mutableMapOf()\n val used = mutableMapOf()\n\n val input = Array(n - 1) {\n readLine()!!.split(\" \").map { it.toInt() - 1 }\n }\n input.forEach { list ->\n val (a, b) = list\n graph[a].add(b)\n used[Points(a, b)] = false\n graph[b].add(a)\n used[Points(b, a)] = false\n }\n fun bfs(from: Int, v: Int, color: Int) {\n //println(\"from:$from to:$v\")\n if (from != -1) {\n used[Points(from, v)] = true\n used[Points(v, from)] = true\n colorMap[Points(from, v)] = color\n colorMap[Points(v, from)] = color\n }\n\n var toColor = 1\n graph[v].forEach { u ->\n if (used[Points(v, u)]!!) return@forEach\n if (color == toColor) {\n toColor++\n bfs(v, u, toColor)\n toColor++\n } else {\n bfs(v, u, toColor)\n toColor++\n }\n }\n }\n bfs(-1, 0, 0)\n println(graph.map { it.size }.max()!!)\n input.forEach { list ->\n val (a, b) = list\n println(colorMap[Points(a, b)])\n }\n}\n\ndata class Points(val u: Int, val v: Int)", "language": "Kotlin", "metadata": {"date": 1574652264, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02850/input.txt", "sample_output_relpath": "derived/input_output/data/p02850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02850/Kotlin/s767027529.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s767027529", "user_id": "u719622470"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n\n val graph = Array(n) {\n mutableListOf()\n }\n val colorMap = mutableMapOf()\n val used = mutableMapOf()\n\n val input = Array(n - 1) {\n readLine()!!.split(\" \").map { it.toInt() - 1 }\n }\n input.forEach { list ->\n val (a, b) = list\n graph[a].add(b)\n used[Points(a, b)] = false\n graph[b].add(a)\n used[Points(b, a)] = false\n }\n fun bfs(from: Int, v: Int, color: Int) {\n //println(\"from:$from to:$v\")\n if (from != -1) {\n used[Points(from, v)] = true\n used[Points(v, from)] = true\n colorMap[Points(from, v)] = color\n colorMap[Points(v, from)] = color\n }\n\n var toColor = 1\n graph[v].forEach { u ->\n if (used[Points(v, u)]!!) return@forEach\n if (color == toColor) {\n toColor++\n bfs(v, u, toColor)\n toColor++\n } else {\n bfs(v, u, toColor)\n toColor++\n }\n }\n }\n bfs(-1, 0, 0)\n println(graph.map { it.size }.max()!!)\n input.forEach { list ->\n val (a, b) = list\n println(colorMap[Points(a, b)])\n }\n}\n\ndata class Points(val u: Int, val v: Int)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["2\n1\n2\n"], "source_document_id": "p02850", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1336, "cpu_time_ms": 1968, "memory_kb": 132712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163756470", "group_id": "codeNet:p02855", "input_text": "fun main(args: Array) {\n val (h, w, k) = readLine()!!.split(' ').map(String::toInt)\n val map = Array(h) { CharArray(w) { '.' } }\n (0 until h).forEach { map[it] = readLine()!!.toCharArray() }\n val ansMap = Array(h) { IntArray(w) { 0 } }\n val sList = mutableListOf>()\n for (th in 0 until h) {\n for (tw in 0 until w) {\n if (map[th][tw] == '#') sList.add(Pair(th, tw))\n }\n }\n var ansNum = 1\n for (s in sList) {\n val (sh, sw) = s\n ansMap[sh][sw] = ansNum\n var tw = sw\n while (true) {\n tw--\n if (tw < 0 || map[sh][tw] == '#') break\n ansMap[sh][tw] = ansNum\n }\n tw = sw\n while (true) {\n tw++\n if (tw >= w || map[sh][tw] == '#' ||ansMap[sh][tw]!=0) break\n ansMap[sh][tw] = ansNum\n }\n ansNum++\n }\n\n for (th in 1 until h) {\n for (tw in 0 until w) {\n if (ansMap[th][tw] == 0) ansMap[th][tw] = ansMap[th - 1][tw]\n }\n }\n\n for (th in (h-2) downTo 0) {\n for (tw in 0 until w) {\n if (ansMap[th][tw] == 0) ansMap[th][tw] = ansMap[th + 1][tw]\n }\n }\n ansMap.forEach {\n println(it.joinToString(\" \"))\n }\n}", "language": "Kotlin", "metadata": {"date": 1574818595, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02855.html", "problem_id": "p02855", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02855/input.txt", "sample_output_relpath": "derived/input_output/data/p02855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02855/Kotlin/s163756470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163756470", "user_id": "u099066216"}, "prompt_components": {"gold_output": "1 2 2\n1 3 4\n5 5 4\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, w, k) = readLine()!!.split(' ').map(String::toInt)\n val map = Array(h) { CharArray(w) { '.' } }\n (0 until h).forEach { map[it] = readLine()!!.toCharArray() }\n val ansMap = Array(h) { IntArray(w) { 0 } }\n val sList = mutableListOf>()\n for (th in 0 until h) {\n for (tw in 0 until w) {\n if (map[th][tw] == '#') sList.add(Pair(th, tw))\n }\n }\n var ansNum = 1\n for (s in sList) {\n val (sh, sw) = s\n ansMap[sh][sw] = ansNum\n var tw = sw\n while (true) {\n tw--\n if (tw < 0 || map[sh][tw] == '#') break\n ansMap[sh][tw] = ansNum\n }\n tw = sw\n while (true) {\n tw++\n if (tw >= w || map[sh][tw] == '#' ||ansMap[sh][tw]!=0) break\n ansMap[sh][tw] = ansNum\n }\n ansNum++\n }\n\n for (th in 1 until h) {\n for (tw in 0 until w) {\n if (ansMap[th][tw] == 0) ansMap[th][tw] = ansMap[th - 1][tw]\n }\n }\n\n for (th in (h-2) downTo 0) {\n for (tw in 0 until w) {\n if (ansMap[th][tw] == 0) ansMap[th][tw] = ansMap[th + 1][tw]\n }\n }\n ansMap.forEach {\n println(it.joinToString(\" \"))\n }\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "sample_input": "3 3 5\n#.#\n.#.\n#.#\n"}, "reference_outputs": ["1 2 2\n1 3 4\n5 5 4\n"], "source_document_id": "p02855", "source_text": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1266, "cpu_time_ms": 478, "memory_kb": 52512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s528660493", "group_id": "codeNet:p02855", "input_text": "fun main(args: Array) {\n val (H, W, K) = readLine()!!.split(\" \").map(String::toInt)\n val F = Array(H) { readLine()!!.toCharArray() }\n val ans = Array(H) { Array(W) { 0 } }\n var p = 1\n for (i in 0..H-1) {\n if (F[i].filter{ x -> x == '#'}.count() != 0) {\n println(\"$i has ${F[i].filter{ x -> x == '#'}.count()}\")\n var first = true\n for (j in 0..W-1) {\n if (F[i][j] == '#') {\n if (!first) { p += 1 }\n first = false\n }\n ans[i][j] = p\n }\n p += 1\n }\n }\n for (i in 1..H-1) {\n if (F[i].filter { x -> x == '#' }.count() == 0) {\n ans[i] = ans[i-1]\n }\n }\n for (i in (H-2).downTo(0)) {\n if (F[i].filter { x -> x == '#' }.count() == 0) {\n ans[i] = ans[i+1]\n }\n }\n ans.forEach { l -> l.forEach{ s -> print(\"$s \") }; println() }\n}", "language": "Kotlin", "metadata": {"date": 1574564325, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02855.html", "problem_id": "p02855", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02855/input.txt", "sample_output_relpath": "derived/input_output/data/p02855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02855/Kotlin/s528660493.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s528660493", "user_id": "u646103151"}, "prompt_components": {"gold_output": "1 2 2\n1 3 4\n5 5 4\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W, K) = readLine()!!.split(\" \").map(String::toInt)\n val F = Array(H) { readLine()!!.toCharArray() }\n val ans = Array(H) { Array(W) { 0 } }\n var p = 1\n for (i in 0..H-1) {\n if (F[i].filter{ x -> x == '#'}.count() != 0) {\n println(\"$i has ${F[i].filter{ x -> x == '#'}.count()}\")\n var first = true\n for (j in 0..W-1) {\n if (F[i][j] == '#') {\n if (!first) { p += 1 }\n first = false\n }\n ans[i][j] = p\n }\n p += 1\n }\n }\n for (i in 1..H-1) {\n if (F[i].filter { x -> x == '#' }.count() == 0) {\n ans[i] = ans[i-1]\n }\n }\n for (i in (H-2).downTo(0)) {\n if (F[i].filter { x -> x == '#' }.count() == 0) {\n ans[i] = ans[i+1]\n }\n }\n ans.forEach { l -> l.forEach{ s -> print(\"$s \") }; println() }\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "sample_input": "3 3 5\n#.#\n.#.\n#.#\n"}, "reference_outputs": ["1 2 2\n1 3 4\n5 5 4\n"], "source_document_id": "p02855", "source_text": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 958, "cpu_time_ms": 787, "memory_kb": 49212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s010395161", "group_id": "codeNet:p02856", "input_text": "import java.util.*\n\nfun f(n: Int): Pair {\n if (n < 10) {\n return Pair(0, 0)\n }\n val s = n.toString()\n\n var mn = 1e8.toInt()\n var mx = 0\n\n for (i in 0 until s.length - 1) {\n val t = s.substring(0, i) + (s[i].toInt() + s[i + 1].toInt() - 2 * '0'.toInt()).toString() + s.substring(i + 2)\n\n val r = f(t.toInt())\n mn = Math.min(mn, r.first + 1)\n mx = Math.min(mn, r.second + 1)\n }\n\n return Pair(mn, mx)\n}\n\nfun update(p: TreeMap): Triple, Long, Boolean> {\n var cnt = 0L\n var updated = false\n val res = TreeMap()\n\n for (e in p) {\n val pair = Pair(e.key, e.value)\n if (pair.second > 1) {\n cnt += pair.second / 2\n val a = pair.first * 2\n\n res[a % 10] = (res[a % 10] ?: 0L) + pair.second / 2\n\n if (a >= 10) {\n res[a / 10] = (res[a / 10] ?: 0L) + pair.second / 2\n }\n\n if (a % 2 == 1L) {\n res[pair.first] = (res[pair.first] ?: 0L) + 1\n }\n updated = true\n } else {\n val v = res.get(pair.first)\n res[pair.first] = v?.plus(pair.second) ?: pair.second\n }\n }\n\n return Triple(res, cnt, updated)\n}\n\nfun main(args: Array) {\n// var q = true\n// for (i in 1..10000) {\n// val r = f(i)\n// val s = f(String(i.toString().toCharArray().sortedDescending().toCharArray()).toInt())\n//// println(\"$i ${r.first} ${r.second}\")\n// q = q && r.first == r.second && r.first == s.first && r.second == s.second\n// if (r.first != r.second || r.first != s.first || r.second != s.second) {\n// println(\"$i $r $s\")\n// }\n// }\n// println(q)\n\n val M = readLine()!!.toInt()\n\n var p = TreeMap()\n\n for(i in 1 .. M) {\n val (d, c) = readLine()!!.split(\" \").map{it.toLong()}\n p[d] = (p[d] ?: 0L) + c\n }\n\n var res = 0L\n\n do {\n val (q, s, f) = update(p)\n res += s\n p = q\n } while(f)\n\n val s = p.map { if (it.value > 0) it.key.toString() else \"\" }.joinToString(\"\")\n var t = String(s.toCharArray().sortedDescending().toCharArray())\n\n while(t.length > 1) {\n res ++\n t = (t[0].toInt() + t[1].toInt() - 2 * '0'.toInt()).toString() + t.substring(2)\n }\n\n println(Math.max(res, 1))\n}\n", "language": "Kotlin", "metadata": {"date": 1574567213, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02856/input.txt", "sample_output_relpath": "derived/input_output/data/p02856/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02856/Kotlin/s010395161.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s010395161", "user_id": "u183530284"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun f(n: Int): Pair {\n if (n < 10) {\n return Pair(0, 0)\n }\n val s = n.toString()\n\n var mn = 1e8.toInt()\n var mx = 0\n\n for (i in 0 until s.length - 1) {\n val t = s.substring(0, i) + (s[i].toInt() + s[i + 1].toInt() - 2 * '0'.toInt()).toString() + s.substring(i + 2)\n\n val r = f(t.toInt())\n mn = Math.min(mn, r.first + 1)\n mx = Math.min(mn, r.second + 1)\n }\n\n return Pair(mn, mx)\n}\n\nfun update(p: TreeMap): Triple, Long, Boolean> {\n var cnt = 0L\n var updated = false\n val res = TreeMap()\n\n for (e in p) {\n val pair = Pair(e.key, e.value)\n if (pair.second > 1) {\n cnt += pair.second / 2\n val a = pair.first * 2\n\n res[a % 10] = (res[a % 10] ?: 0L) + pair.second / 2\n\n if (a >= 10) {\n res[a / 10] = (res[a / 10] ?: 0L) + pair.second / 2\n }\n\n if (a % 2 == 1L) {\n res[pair.first] = (res[pair.first] ?: 0L) + 1\n }\n updated = true\n } else {\n val v = res.get(pair.first)\n res[pair.first] = v?.plus(pair.second) ?: pair.second\n }\n }\n\n return Triple(res, cnt, updated)\n}\n\nfun main(args: Array) {\n// var q = true\n// for (i in 1..10000) {\n// val r = f(i)\n// val s = f(String(i.toString().toCharArray().sortedDescending().toCharArray()).toInt())\n//// println(\"$i ${r.first} ${r.second}\")\n// q = q && r.first == r.second && r.first == s.first && r.second == s.second\n// if (r.first != r.second || r.first != s.first || r.second != s.second) {\n// println(\"$i $r $s\")\n// }\n// }\n// println(q)\n\n val M = readLine()!!.toInt()\n\n var p = TreeMap()\n\n for(i in 1 .. M) {\n val (d, c) = readLine()!!.split(\" \").map{it.toLong()}\n p[d] = (p[d] ?: 0L) + c\n }\n\n var res = 0L\n\n do {\n val (q, s, f) = update(p)\n res += s\n p = q\n } while(f)\n\n val s = p.map { if (it.value > 0) it.key.toString() else \"\" }.joinToString(\"\")\n var t = String(s.toCharArray().sortedDescending().toCharArray())\n\n while(t.length > 1) {\n res ++\n t = (t[0].toInt() + t[1].toInt() - 2 * '0'.toInt()).toString() + t.substring(2)\n }\n\n println(Math.max(res, 1))\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "sample_input": "2\n2 2\n9 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02856", "source_text": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2389, "cpu_time_ms": 664, "memory_kb": 72920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s104370302", "group_id": "codeNet:p02859", "input_text": "fun main (args:Array){\n val rRadius = readLine()!!.toInt()\n print(rRadius * rRadius)\n}\n", "language": "Kotlin", "metadata": {"date": 1596121487, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/Kotlin/s104370302.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104370302", "user_id": "u838133978"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main (args:Array){\n val rRadius = readLine()!!.toInt()\n print(rRadius * rRadius)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 101, "cpu_time_ms": 96, "memory_kb": 34468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s751748298", "group_id": "codeNet:p02859", "input_text": "fun main(args: Array){\n val r = readLine()!!.toInt()\n print(r*r)\n}", "language": "Kotlin", "metadata": {"date": 1586404389, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/Kotlin/s751748298.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s751748298", "user_id": "u446699896"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array){\n val r = readLine()!!.toInt()\n print(r*r)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 208, "memory_kb": 31716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s160411878", "group_id": "codeNet:p02860", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val s = sc.next()\n println(problem145b(n, s))\n}\n\nfun problem145b(n: Int, s: String): String {\n if (s.length % 2 != 0) return \"No\"\n return if (s.take(n / 2) == s.takeLast(n / 2)) \"Yes\" else \"No\"\n}", "language": "Kotlin", "metadata": {"date": 1573956534, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/Kotlin/s160411878.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160411878", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val s = sc.next()\n println(problem145b(n, s))\n}\n\nfun problem145b(n: Int, s: String): String {\n if (s.length % 2 != 0) return \"No\"\n return if (s.take(n / 2) == s.takeLast(n / 2)) \"Yes\" else \"No\"\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 195, "memory_kb": 29600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s085831630", "group_id": "codeNet:p02861", "input_text": "import java.io.*\nimport java.util.*\n\nfun square(x: Int) = x * x\n\nfun solve(N: Int, x: IntArray, y: IntArray){\n fun dist(i: Int, j: Int) =\n Math.sqrt((square(x[i] - x[j]) + square(y[i] - y[j])).toDouble())\n val perms = (0 until N).toList().permutations()\n perms.map{\n perm -> perm.zipWithNext{ a, b -> dist(a,b) }.sum()\n }.average().let{ println(it) }\n return\n}\n\nfun List.zipWithNext(transform: (a: T, b:T) -> R): List{\n return (0 until size - 1).map{ transform(this[it], this[it+1]) }\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val x = IntArray(N)\n val y = IntArray(N)\n for (i in 0 until N) {\n x[i] = sc.next().toInt()\n y[i] = sc.next().toInt()\n }\n solve(N, x, y)\n}\n\n\nfun List.dot(other: List): Int =\n this.mapIndexed { index, value -> value * other[index] }.sum()\n\nfun List.dot(other: List): Long =\n this.mapIndexed { index, value -> value * other[index] }.sum()\n\nfun concat(left: T, right: T): List = listOf(left, right)\nfun concat(left: List, right: T): List = left + right\nfun concat(left: List, right: List): List> = right.map{ concat(left, it) }\n\nfun product(vararg lists: List): Sequence> {\n fun productTwoList(left: List, right: List): Sequence> =\n left.asSequence().flatMap { leftElem -> right.asSequence().map { listOf(leftElem, it) } }\n\n fun product2DListAnd1DList(list2D: Sequence>, list1D: List): Sequence> =\n list2D.flatMap { seq -> list1D.asSequence().map { seq + it } }\n\n require(lists.size >= 2)\n return lists.asSequence()\n .drop(2)\n .fold(productTwoList(lists[0], lists[1])) { acc, suc -> product2DListAnd1DList(acc, suc) }\n}\n\nfun Collection.powerSet(): Set> = powerSet(this, setOf(setOf()))\n\nprivate tailrec fun powerSet(left: Collection, acc: Set>): Set> = when {\n left.isEmpty() -> acc\n else -> powerSet(left.drop(1), acc + acc.map { it + left.first() })\n}\n\nfun Set.combinations(n: Int): Set> = when {\n n < 0 -> throw Error(\"n must be positive, but got $n\")\n n == 0 -> setOf(setOf())\n n >= size -> setOf(toSet())\n else -> powerSet()\n .filter { it.size == n }\n .toSet()\n}\n\nfun List.insert(index: Int, element: T): List = when {\n index < 0 || index > size -> throw Error(\"Can not insert to index = $index\")\n index == 0 -> listOf(element) + this\n index == size -> this + element\n else -> dropLast(size - index) + element + drop(index)\n}\n\nfun List.permutations(): Set> = when {\n isEmpty() -> setOf()\n size == 1 -> setOf(listOf(get(0)))\n else -> {\n val element = get(0)\n drop(1).permutations()\n .flatMap { sublist -> (0..sublist.size).map { i -> sublist.insert(i, element) } }\n .toSet()\n }\n}\n\nfun Iterable.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence {\n var last = initial\n return this.asSequence().map { last = operation(last, it); last }\n}\n", "language": "Kotlin", "metadata": {"date": 1574111621, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02861.html", "problem_id": "p02861", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02861/input.txt", "sample_output_relpath": "derived/input_output/data/p02861/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02861/Kotlin/s085831630.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085831630", "user_id": "u329232967"}, "prompt_components": {"gold_output": "2.2761423749\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun square(x: Int) = x * x\n\nfun solve(N: Int, x: IntArray, y: IntArray){\n fun dist(i: Int, j: Int) =\n Math.sqrt((square(x[i] - x[j]) + square(y[i] - y[j])).toDouble())\n val perms = (0 until N).toList().permutations()\n perms.map{\n perm -> perm.zipWithNext{ a, b -> dist(a,b) }.sum()\n }.average().let{ println(it) }\n return\n}\n\nfun List.zipWithNext(transform: (a: T, b:T) -> R): List{\n return (0 until size - 1).map{ transform(this[it], this[it+1]) }\n}\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val x = IntArray(N)\n val y = IntArray(N)\n for (i in 0 until N) {\n x[i] = sc.next().toInt()\n y[i] = sc.next().toInt()\n }\n solve(N, x, y)\n}\n\n\nfun List.dot(other: List): Int =\n this.mapIndexed { index, value -> value * other[index] }.sum()\n\nfun List.dot(other: List): Long =\n this.mapIndexed { index, value -> value * other[index] }.sum()\n\nfun concat(left: T, right: T): List = listOf(left, right)\nfun concat(left: List, right: T): List = left + right\nfun concat(left: List, right: List): List> = right.map{ concat(left, it) }\n\nfun product(vararg lists: List): Sequence> {\n fun productTwoList(left: List, right: List): Sequence> =\n left.asSequence().flatMap { leftElem -> right.asSequence().map { listOf(leftElem, it) } }\n\n fun product2DListAnd1DList(list2D: Sequence>, list1D: List): Sequence> =\n list2D.flatMap { seq -> list1D.asSequence().map { seq + it } }\n\n require(lists.size >= 2)\n return lists.asSequence()\n .drop(2)\n .fold(productTwoList(lists[0], lists[1])) { acc, suc -> product2DListAnd1DList(acc, suc) }\n}\n\nfun Collection.powerSet(): Set> = powerSet(this, setOf(setOf()))\n\nprivate tailrec fun powerSet(left: Collection, acc: Set>): Set> = when {\n left.isEmpty() -> acc\n else -> powerSet(left.drop(1), acc + acc.map { it + left.first() })\n}\n\nfun Set.combinations(n: Int): Set> = when {\n n < 0 -> throw Error(\"n must be positive, but got $n\")\n n == 0 -> setOf(setOf())\n n >= size -> setOf(toSet())\n else -> powerSet()\n .filter { it.size == n }\n .toSet()\n}\n\nfun List.insert(index: Int, element: T): List = when {\n index < 0 || index > size -> throw Error(\"Can not insert to index = $index\")\n index == 0 -> listOf(element) + this\n index == size -> this + element\n else -> dropLast(size - index) + element + drop(index)\n}\n\nfun List.permutations(): Set> = when {\n isEmpty() -> setOf()\n size == 1 -> setOf(listOf(get(0)))\n else -> {\n val element = get(0)\n drop(1).permutations()\n .flatMap { sublist -> (0..sublist.size).map { i -> sublist.insert(i, element) } }\n .toSet()\n }\n}\n\nfun Iterable.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence {\n var last = initial\n return this.asSequence().map { last = operation(last, it); last }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \\sqrt{\\left(x_i-x_j\\right)^2+\\left(y_i-y_j\\right)^2}.\n\nThere are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \\dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.\n\nConstraints\n\n2 \\leq N \\leq 8\n\n-1000 \\leq x_i \\leq 1000\n\n-1000 \\leq y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) (if i \\neq j)\n\n(Added 21:12 JST) All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the average length of the paths.\nYour output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n3\n0 0\n1 0\n0 1\n\nSample Output 1\n\n2.2761423749\n\nThere are six paths to visit the towns: 1 → 2 → 3, 1 → 3 → 2, 2 → 1 → 3, 2 → 3 → 1, 3 → 1 → 2, and 3 → 2 → 1.\n\nThe length of the path 1 → 2 → 3 is \\sqrt{\\left(0-1\\right)^2+\\left(0-0\\right)^2} + \\sqrt{\\left(1-0\\right)^2+\\left(0-1\\right)^2} = 1+\\sqrt{2}.\n\nBy calculating the lengths of the other paths in this way, we see that the average length of all routes is:\n\n\\frac{\\left(1+\\sqrt{2}\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)}{6} = 2.276142...\n\nSample Input 2\n\n2\n-879 981\n-866 890\n\nSample Output 2\n\n91.9238815543\n\nThere are two paths to visit the towns: 1 → 2 and 2 → 1. These paths have the same length.\n\nSample Input 3\n\n8\n-406 10\n512 859\n494 362\n-955 -475\n128 553\n-986 -885\n763 77\n449 310\n\nSample Output 3\n\n7641.9817824387", "sample_input": "3\n0 0\n1 0\n0 1\n"}, "reference_outputs": ["2.2761423749\n"], "source_document_id": "p02861", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \\sqrt{\\left(x_i-x_j\\right)^2+\\left(y_i-y_j\\right)^2}.\n\nThere are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \\dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.\n\nConstraints\n\n2 \\leq N \\leq 8\n\n-1000 \\leq x_i \\leq 1000\n\n-1000 \\leq y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) (if i \\neq j)\n\n(Added 21:12 JST) All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the average length of the paths.\nYour output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n3\n0 0\n1 0\n0 1\n\nSample Output 1\n\n2.2761423749\n\nThere are six paths to visit the towns: 1 → 2 → 3, 1 → 3 → 2, 2 → 1 → 3, 2 → 3 → 1, 3 → 1 → 2, and 3 → 2 → 1.\n\nThe length of the path 1 → 2 → 3 is \\sqrt{\\left(0-1\\right)^2+\\left(0-0\\right)^2} + \\sqrt{\\left(1-0\\right)^2+\\left(0-1\\right)^2} = 1+\\sqrt{2}.\n\nBy calculating the lengths of the other paths in this way, we see that the average length of all routes is:\n\n\\frac{\\left(1+\\sqrt{2}\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)}{6} = 2.276142...\n\nSample Input 2\n\n2\n-879 981\n-866 890\n\nSample Output 2\n\n91.9238815543\n\nThere are two paths to visit the towns: 1 → 2 and 2 → 1. These paths have the same length.\n\nSample Input 3\n\n8\n-406 10\n512 859\n494 362\n-955 -475\n128 553\n-986 -885\n763 77\n449 310\n\nSample Output 3\n\n7641.9817824387", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3657, "cpu_time_ms": 514, "memory_kb": 56564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s047888341", "group_id": "codeNet:p02862", "input_text": "fun main(args: Array) {\n val (x, y) = readIntegerList()\n if (y * 2 < x || x * 2 < y || (x + y) % 3 != 0) {\n println(0)\n return\n }\n\n// y = -x + b\n// b = y1 + x1\n// y = -x + x1 + y1\n// -----------\n// y = x / 2\n// -2x + 2x1 + 2y1 = x\n// x = 2 * (x1 + y1) / 3\n// y = (x1 + y1) / 3\n val lowX = 2 * (x + y) / 3\n val lowY = (x + y) / 3\n val cX = lowX / 2\n val cY = y - lowY\n val table = Combination(10000000)\n println(table.value(cX, cY))\n\n}\n\n/** n <= 1000000 */\nclass Combination(n: Int, val MOD: Long = 1000000007L) {\n val fact = LongArray(n + 1)\n val ifact = LongArray(n + 1)\n\n /** O(n) */\n init {\n fact[0] = 1L\n for (i in 1..n) { fact[i] = (fact[i - 1] * i) % MOD }\n ifact[n] = inverse(fact[n], MOD)\n for (i in n downTo 1) { ifact[i - 1] = (ifact[i] * i) % MOD }\n }\n\n /** O(1) */\n fun value(n: Int, k: Int) = if (k < 0 || k > n) 0 else (((fact[n] * ifact[k]) % MOD) * ifact[n-k]) % MOD\n\n /** O(log(m)) */\n fun pow(n: Long, m: Long, MOD: Long): Long {\n var ret = 1L\n var x = n\n var k = m\n while (k > 0) {\n if ((k and 1L) == 1L) { ret = (ret * x) % MOD }\n x = (x * x) % MOD\n k = k shr 1\n }\n return ret\n }\n\n /** O(log(MOD)) */\n fun inverse(n: Long, MOD: Long) = pow(n, MOD - 2L, MOD)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1584295700, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02862/input.txt", "sample_output_relpath": "derived/input_output/data/p02862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02862/Kotlin/s047888341.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s047888341", "user_id": "u784448849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readIntegerList()\n if (y * 2 < x || x * 2 < y || (x + y) % 3 != 0) {\n println(0)\n return\n }\n\n// y = -x + b\n// b = y1 + x1\n// y = -x + x1 + y1\n// -----------\n// y = x / 2\n// -2x + 2x1 + 2y1 = x\n// x = 2 * (x1 + y1) / 3\n// y = (x1 + y1) / 3\n val lowX = 2 * (x + y) / 3\n val lowY = (x + y) / 3\n val cX = lowX / 2\n val cY = y - lowY\n val table = Combination(10000000)\n println(table.value(cX, cY))\n\n}\n\n/** n <= 1000000 */\nclass Combination(n: Int, val MOD: Long = 1000000007L) {\n val fact = LongArray(n + 1)\n val ifact = LongArray(n + 1)\n\n /** O(n) */\n init {\n fact[0] = 1L\n for (i in 1..n) { fact[i] = (fact[i - 1] * i) % MOD }\n ifact[n] = inverse(fact[n], MOD)\n for (i in n downTo 1) { ifact[i - 1] = (ifact[i] * i) % MOD }\n }\n\n /** O(1) */\n fun value(n: Int, k: Int) = if (k < 0 || k > n) 0 else (((fact[n] * ifact[k]) % MOD) * ifact[n-k]) % MOD\n\n /** O(log(m)) */\n fun pow(n: Long, m: Long, MOD: Long): Long {\n var ret = 1L\n var x = n\n var k = m\n while (k > 0) {\n if ((k and 1L) == 1L) { ret = (ret * x) % MOD }\n x = (x * x) % MOD\n k = k shr 1\n }\n return ret\n }\n\n /** O(log(MOD)) */\n fun inverse(n: Long, MOD: Long) = pow(n, MOD - 2L, MOD)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "sample_input": "3 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02862", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1638, "cpu_time_ms": 604, "memory_kb": 196212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s850587894", "group_id": "codeNet:p02862", "input_text": "fun main(args: Array) {\n fun pow(a: Long, b: Long, mod: Int): Long {\n var bt = b\n var ret: Long = 1\n var tmp = a\n while (bt > 0) {\n if (bt and 1 == 1L) ret = ret * tmp % mod\n tmp = tmp * tmp % mod\n bt = bt shr 1\n }\n return ret\n }\n\n fun nCk(n: Int, k: Int, M: Int): Int {\n var ret: Long = 1\n val min = Math.min(k, n - k)\n for (i in 1..min) {\n ret = ret * pow(i.toLong(), (M - 2).toLong(), M) % M\n }\n for (i in n - min + 1..n) {\n ret = ret * i % M\n }\n return ret.toInt()\n }\n\n\n val mod = 1000000007L\n val (x, y) = readLine()!!.split(' ').map(String::toLong)\n\n val totalMove = (x + y) / 3\n val countU = y - totalMove\n val countR = x - totalMove\n if ((x + y) % 3 != 0L || countU < 0 || countR < 0) {\n println(0)\n return\n }\n println(nCk(totalMove.toInt(), countR.toInt(), mod.toInt()) % mod)\n}", "language": "Kotlin", "metadata": {"date": 1573958509, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02862/input.txt", "sample_output_relpath": "derived/input_output/data/p02862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02862/Kotlin/s850587894.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850587894", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n fun pow(a: Long, b: Long, mod: Int): Long {\n var bt = b\n var ret: Long = 1\n var tmp = a\n while (bt > 0) {\n if (bt and 1 == 1L) ret = ret * tmp % mod\n tmp = tmp * tmp % mod\n bt = bt shr 1\n }\n return ret\n }\n\n fun nCk(n: Int, k: Int, M: Int): Int {\n var ret: Long = 1\n val min = Math.min(k, n - k)\n for (i in 1..min) {\n ret = ret * pow(i.toLong(), (M - 2).toLong(), M) % M\n }\n for (i in n - min + 1..n) {\n ret = ret * i % M\n }\n return ret.toInt()\n }\n\n\n val mod = 1000000007L\n val (x, y) = readLine()!!.split(' ').map(String::toLong)\n\n val totalMove = (x + y) / 3\n val countU = y - totalMove\n val countR = x - totalMove\n if ((x + y) % 3 != 0L || countU < 0 || countR < 0) {\n println(0)\n return\n }\n println(nCk(totalMove.toInt(), countR.toInt(), mod.toInt()) % mod)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "sample_input": "3 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02862", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 991, "cpu_time_ms": 454, "memory_kb": 38324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s673878730", "group_id": "codeNet:p02863", "input_text": "fun main(args: Array) = yorukatsu8e()\n\nfun yorukatsu8e() {\n val (n, t) = readLine()!!.split(' ').map { it.toInt() }\n val foods = (1..n).map {\n readLine()!!.split(' ').map { it.toInt() }.let { Food(it[0], it[1]) }\n }.sortedBy { it.time }\n\n val dp = Array(n + 1) { IntArray(t) }\n var answer = 0\n\n for (i in 1..n) {\n val food = foods[i - 1]\n for (time in 0 until t) {\n dp[i][time] = dp[i - 1][time]\n answer = Math.max(answer, dp[i][time] + food.point)\n if (time - food.time >= 0) {\n dp[i][time] = Math.max(\n dp[i][time],\n dp[i - 1][time - food.time] + food.point\n )\n }\n }\n }\n\n println(answer)\n}\n\nprivate data class Food(val time: Int, val point: Int)\n", "language": "Kotlin", "metadata": {"date": 1586234966, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02863.html", "problem_id": "p02863", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02863/input.txt", "sample_output_relpath": "derived/input_output/data/p02863/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02863/Kotlin/s673878730.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s673878730", "user_id": "u139478771"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu8e()\n\nfun yorukatsu8e() {\n val (n, t) = readLine()!!.split(' ').map { it.toInt() }\n val foods = (1..n).map {\n readLine()!!.split(' ').map { it.toInt() }.let { Food(it[0], it[1]) }\n }.sortedBy { it.time }\n\n val dp = Array(n + 1) { IntArray(t) }\n var answer = 0\n\n for (i in 1..n) {\n val food = foods[i - 1]\n for (time in 0 until t) {\n dp[i][time] = dp[i - 1][time]\n answer = Math.max(answer, dp[i][time] + food.point)\n if (time - food.time >= 0) {\n dp[i][time] = Math.max(\n dp[i][time],\n dp[i - 1][time - food.time] + food.point\n )\n }\n }\n }\n\n println(answer)\n}\n\nprivate data class Food(val time: Int, val point: Int)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "sample_input": "2 60\n10 10\n100 100\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02863", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 820, "cpu_time_ms": 477, "memory_kb": 85944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s561025919", "group_id": "codeNet:p02865", "input_text": "fun main(args: Array) {\n println((readLine()!!.toInt()-1)/2)\n}", "language": "Kotlin", "metadata": {"date": 1573582330, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02865.html", "problem_id": "p02865", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02865/input.txt", "sample_output_relpath": "derived/input_output/data/p02865/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02865/Kotlin/s561025919.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561025919", "user_id": "u808160425"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n println((readLine()!!.toInt()-1)/2)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many ways are there to choose two distinct positive integers totaling N, disregarding the order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n\nThere is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)\n\nSample Input 2\n\n999999\n\nSample Output 2\n\n499999", "sample_input": "4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02865", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many ways are there to choose two distinct positive integers totaling N, disregarding the order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n\nThere is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)\n\nSample Input 2\n\n999999\n\nSample Output 2\n\n499999", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 71, "cpu_time_ms": 206, "memory_kb": 31748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s112645790", "group_id": "codeNet:p02866", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = (0 until n).map { sc.next().toInt() }\n println(problemnikkei20192b(n, d))\n}\n\nfun problemnikkei20192b(n: Int, d: List): Long {\n if (d[0] != 0) return 0\n\n val mod = fun(n: Long) = n % 998244353\n val groped = d.sorted().groupBy { it }.toList()\n var ans = 1L\n for (i in 1 until groped.size) {\n for (j in 0 until groped[i].second.size) {\n ans = mod(ans * groped[i- 1].second.size)\n }\n }\n return 0\n}", "language": "Kotlin", "metadata": {"date": 1573426429, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Kotlin/s112645790.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s112645790", "user_id": "u073232808"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = (0 until n).map { sc.next().toInt() }\n println(problemnikkei20192b(n, d))\n}\n\nfun problemnikkei20192b(n: Int, d: List): Long {\n if (d[0] != 0) return 0\n\n val mod = fun(n: Long) = n % 998244353\n val groped = d.sorted().groupBy { it }.toList()\n var ans = 1L\n for (i in 1 until groped.size) {\n for (j in 0 until groped[i].second.size) {\n ans = mod(ans * groped[i- 1].second.size)\n }\n }\n return 0\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 570, "cpu_time_ms": 1379, "memory_kb": 84260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s560183850", "group_id": "codeNet:p02866", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = (0 until n).map { sc.next().toInt() }\n println(problemnikkei20192b(n, d))\n}\n\nfun problemnikkei20192b(n: Int, d: List): Long {\n if (d[0] != 0) return 0\n\n val mod = fun(n: Long) = n % 998244353\n val groped = d.sorted().groupBy { it }.toList()\n var ans = 1L\n for (i in 1 until groped.size) {\n ans *= Math.pow(groped[i - 1].second.size.toDouble(), groped[i].second.size.toDouble()).toLong()\n ans = mod(ans)\n }\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1573424670, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Kotlin/s560183850.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s560183850", "user_id": "u073232808"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = (0 until n).map { sc.next().toInt() }\n println(problemnikkei20192b(n, d))\n}\n\nfun problemnikkei20192b(n: Int, d: List): Long {\n if (d[0] != 0) return 0\n\n val mod = fun(n: Long) = n % 998244353\n val groped = d.sorted().groupBy { it }.toList()\n var ans = 1L\n for (i in 1 until groped.size) {\n ans *= Math.pow(groped[i - 1].second.size.toDouble(), groped[i].second.size.toDouble()).toLong()\n ans = mod(ans)\n }\n return ans\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 585, "cpu_time_ms": 1358, "memory_kb": 80368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s827233671", "group_id": "codeNet:p02866", "input_text": "fun main(args: Array) {\n nikkei20192quala_b()\n}\n\nprivate fun mod(x: Long) = x % (998244353).toLong()\n\nfun nikkei20192quala_b() {\n val n = readLine()!!.toInt()\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n\n val eachCount = dList.groupBy { it }.mapValues { it.value.size }\n\n if (eachCount[0] == null) return println(0)\n\n var answer = 1L\n var depth = 0\n while (eachCount[depth + 1] != null) {\n depth++\n answer *= mod(Math.pow(eachCount[depth - 1]?.toDouble() ?: 0.0, eachCount[depth]?.toDouble() ?: 0.0).toLong())\n }\n\n val last = eachCount.keys.max()!!\n\n if (depth < last) return println(0)\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1573371479, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Kotlin/s827233671.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s827233671", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n nikkei20192quala_b()\n}\n\nprivate fun mod(x: Long) = x % (998244353).toLong()\n\nfun nikkei20192quala_b() {\n val n = readLine()!!.toInt()\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n\n val eachCount = dList.groupBy { it }.mapValues { it.value.size }\n\n if (eachCount[0] == null) return println(0)\n\n var answer = 1L\n var depth = 0\n while (eachCount[depth + 1] != null) {\n depth++\n answer *= mod(Math.pow(eachCount[depth - 1]?.toDouble() ?: 0.0, eachCount[depth]?.toDouble() ?: 0.0).toLong())\n }\n\n val last = eachCount.keys.max()!!\n\n if (depth < last) return println(0)\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 677, "cpu_time_ms": 768, "memory_kb": 83048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s170750316", "group_id": "codeNet:p02866", "input_text": "fun main(args: Array) {\n nikkei20192quala_b()\n}\n\nprivate fun mod(x: Long) = x % (998244353).toLong()\n\nfun nikkei20192quala_b() {\n val n = readLine()!!.toInt()\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n\n val eachCount = dList.groupBy { it }.mapValues { it.value.size }\n\n if (eachCount[0] == null) return println(0)\n\n var answer = 1L\n var depth = 1\n while (eachCount[depth] != null) {\n answer *= mod(Math.pow(eachCount[depth - 1]?.toDouble() ?: 0.0, eachCount[depth]?.toDouble() ?: 0.0).toLong())\n depth++\n }\n\n val last = eachCount.keys.max()!!\n\n if (depth < last) return println(0)\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1573371416, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Kotlin/s170750316.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s170750316", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n nikkei20192quala_b()\n}\n\nprivate fun mod(x: Long) = x % (998244353).toLong()\n\nfun nikkei20192quala_b() {\n val n = readLine()!!.toInt()\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n\n val eachCount = dList.groupBy { it }.mapValues { it.value.size }\n\n if (eachCount[0] == null) return println(0)\n\n var answer = 1L\n var depth = 1\n while (eachCount[depth] != null) {\n answer *= mod(Math.pow(eachCount[depth - 1]?.toDouble() ?: 0.0, eachCount[depth]?.toDouble() ?: 0.0).toLong())\n depth++\n }\n\n val last = eachCount.keys.max()!!\n\n if (depth < last) return println(0)\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 673, "cpu_time_ms": 772, "memory_kb": 85420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s386568203", "group_id": "codeNet:p02867", "input_text": "import java.util.Scanner\nimport kotlin.system.exitProcess\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval la = IntArray(n){scn.nextInt()}\n\tval lb = IntArray(n){scn.nextInt()}\n\tval ordA = la.indices.sortedBy { la[it] }.toIntArray()\n\tval ordB = lb.indices.sortedBy { lb[it] }.toIntArray()\n\tif (ordA.indices.any{la[ordA[it]]>lb[ordB[it]]}) ans(false)\n\tvar k = ordB[0]\n\tvar cnt = 0\n\twhile(true){\n\t\tk = ordA[ordB[k]]\n\t\tcnt++\n\t\tif (k==ordB[0]) break\n\t}\n\tif (cnt!=n) ans(true)\n\tans((0 until n-1).any{lb[ordB[it]]>=la[ordA[ordB[it+1]]]})\n}\n\nfun ans(ans: Boolean){\n\tprintln(if (ans) \"Yes\" else \"No\")\n\texitProcess(0)\n}", "language": "Kotlin", "metadata": {"date": 1573362884, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02867.html", "problem_id": "p02867", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02867/input.txt", "sample_output_relpath": "derived/input_output/data/p02867/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02867/Kotlin/s386568203.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s386568203", "user_id": "u914590612"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\nimport kotlin.system.exitProcess\n\nfun main(args: Array) {\n\tval scn = Scanner(System.`in`)\n\tval n = scn.nextInt()\n\tval la = IntArray(n){scn.nextInt()}\n\tval lb = IntArray(n){scn.nextInt()}\n\tval ordA = la.indices.sortedBy { la[it] }.toIntArray()\n\tval ordB = lb.indices.sortedBy { lb[it] }.toIntArray()\n\tif (ordA.indices.any{la[ordA[it]]>lb[ordB[it]]}) ans(false)\n\tvar k = ordB[0]\n\tvar cnt = 0\n\twhile(true){\n\t\tk = ordA[ordB[k]]\n\t\tcnt++\n\t\tif (k==ordB[0]) break\n\t}\n\tif (cnt!=n) ans(true)\n\tans((0 until n-1).any{lb[ordB[it]]>=la[ordA[ordB[it+1]]]})\n}\n\nfun ans(ans: Boolean){\n\tprintln(if (ans) \"Yes\" else \"No\")\n\texitProcess(0)\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "sample_input": "3\n1 3 2\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02867", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 653, "cpu_time_ms": 1187, "memory_kb": 115316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s602713936", "group_id": "codeNet:p02873", "input_text": "fun main(args : Array) {\n var s = readLine()!!\n\n var prev = '-'\n var greater = 0\n var smaller = 0\n\n val ss = mutableListOf()\n\n s.forEach {\n if (it == '<') {\n if (prev == '-' || prev== '<') {\n greater++\n } else {\n ss.add(smaller)\n greater++\n smaller = 0\n }\n prev = '<'\n } else {\n if (prev == '-' || prev== '>') {\n smaller--\n } else {\n ss.add(greater)\n smaller--\n greater = 0\n }\n prev = '>'\n }\n }\n\n if (greater > 0) {\n ss.add(greater)\n }\n if (smaller < 0) {\n ss.add(smaller)\n }\n\n var ans = 0\n var last = 0\n for (i in ss.indices) {\n if (ss[i] > 0) { // '<'\n repeat(ss[i]-1) {\n ans += (it+1)\n }\n last = ss[i]-1\n\n if (i == ss.size-1) {\n repeat(ss[i]) {\n ans += it+1\n }\n }\n\n } else { // '>'\n if (last < -ss[i]) {\n repeat(-ss[i]) {\n ans += (it+1)\n }\n } else {\n ans += last+1\n repeat(-ss[i]-1) {\n ans += (it+1)\n }\n }\n }\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1572847497, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02873.html", "problem_id": "p02873", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02873/input.txt", "sample_output_relpath": "derived/input_output/data/p02873/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02873/Kotlin/s602713936.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s602713936", "user_id": "u262403099"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args : Array) {\n var s = readLine()!!\n\n var prev = '-'\n var greater = 0\n var smaller = 0\n\n val ss = mutableListOf()\n\n s.forEach {\n if (it == '<') {\n if (prev == '-' || prev== '<') {\n greater++\n } else {\n ss.add(smaller)\n greater++\n smaller = 0\n }\n prev = '<'\n } else {\n if (prev == '-' || prev== '>') {\n smaller--\n } else {\n ss.add(greater)\n smaller--\n greater = 0\n }\n prev = '>'\n }\n }\n\n if (greater > 0) {\n ss.add(greater)\n }\n if (smaller < 0) {\n ss.add(smaller)\n }\n\n var ans = 0\n var last = 0\n for (i in ss.indices) {\n if (ss[i] > 0) { // '<'\n repeat(ss[i]-1) {\n ans += (it+1)\n }\n last = ss[i]-1\n\n if (i == ss.size-1) {\n repeat(ss[i]) {\n ans += it+1\n }\n }\n\n } else { // '>'\n if (last < -ss[i]) {\n repeat(-ss[i]) {\n ans += (it+1)\n }\n } else {\n ans += last+1\n repeat(-ss[i]-1) {\n ans += (it+1)\n }\n }\n }\n }\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "sample_input": "<>>\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02873", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1426, "cpu_time_ms": 319, "memory_kb": 39260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s184663069", "group_id": "codeNet:p02874", "input_text": "fun main(args: Array) {\n agc040b()\n}\n\nprivate data class Problem(val lower: Long, val upper: Long)\n\nfun agc040b() {\n val n = readLine()!!.toInt()\n val problems = (1..n).map { readLine()!!.split(\" \").map { it.toLong() } }\n .map { Problem(it[0], it[1]) }\n .sortedByDescending { it.upper - it.lower }\n\n var groupA = problems[0]\n var groupB = problems[1]\n for (i in 2..problems.lastIndex) {\n val problem = problems[i]\n\n val diffA = groupA.upper - groupA.lower + 1 -\n Math.max(0, Math.min(groupA.upper, problem.upper) - Math.max(groupA.lower, problem.lower))\n val diffB = groupB.upper - groupB.lower + 1 -\n Math.max(0, Math.min(groupB.upper, problem.upper) - Math.max(groupB.lower, problem.lower))\n\n if (diffA < diffB) {\n groupA = Problem(Math.max(groupA.lower, problem.lower), Math.min(groupA.upper, problem.upper))\n } else {\n groupB = Problem(Math.max(groupB.lower, problem.lower), Math.min(groupB.upper, problem.upper))\n }\n }\n\n var groupA2 = problems[0]\n var groupB2 = problems[2]\n for (i in 1..problems.lastIndex) {\n val problem = problems[i]\n\n val diffA = groupA2.upper - groupA2.lower + 1 -\n Math.max(0, Math.min(groupA2.upper, problem.upper) - Math.max(groupA2.lower, problem.lower))\n val diffB = groupB2.upper - groupB2.lower + 1 -\n Math.max(0, Math.min(groupB2.upper, problem.upper) - Math.max(groupB2.lower, problem.lower))\n\n if (diffA < diffB) {\n groupA2 = Problem(Math.max(groupA2.lower, problem.lower), Math.min(groupA2.upper, problem.upper))\n } else {\n groupB2 = Problem(Math.max(groupB2.lower, problem.lower), Math.min(groupB2.upper, problem.upper))\n }\n }\n\n\n val answer = Math.min(\n Math.max(0, groupA.upper - groupA.lower + 1) + Math.max(0, groupB.upper - groupB.lower + 1),\n Math.max(0, groupA2.upper - groupA2.lower + 1) + Math.max(0, groupB2.upper - groupB2.lower + 1)\n )\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1572851772, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02874.html", "problem_id": "p02874", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02874/input.txt", "sample_output_relpath": "derived/input_output/data/p02874/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02874/Kotlin/s184663069.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s184663069", "user_id": "u139478771"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n agc040b()\n}\n\nprivate data class Problem(val lower: Long, val upper: Long)\n\nfun agc040b() {\n val n = readLine()!!.toInt()\n val problems = (1..n).map { readLine()!!.split(\" \").map { it.toLong() } }\n .map { Problem(it[0], it[1]) }\n .sortedByDescending { it.upper - it.lower }\n\n var groupA = problems[0]\n var groupB = problems[1]\n for (i in 2..problems.lastIndex) {\n val problem = problems[i]\n\n val diffA = groupA.upper - groupA.lower + 1 -\n Math.max(0, Math.min(groupA.upper, problem.upper) - Math.max(groupA.lower, problem.lower))\n val diffB = groupB.upper - groupB.lower + 1 -\n Math.max(0, Math.min(groupB.upper, problem.upper) - Math.max(groupB.lower, problem.lower))\n\n if (diffA < diffB) {\n groupA = Problem(Math.max(groupA.lower, problem.lower), Math.min(groupA.upper, problem.upper))\n } else {\n groupB = Problem(Math.max(groupB.lower, problem.lower), Math.min(groupB.upper, problem.upper))\n }\n }\n\n var groupA2 = problems[0]\n var groupB2 = problems[2]\n for (i in 1..problems.lastIndex) {\n val problem = problems[i]\n\n val diffA = groupA2.upper - groupA2.lower + 1 -\n Math.max(0, Math.min(groupA2.upper, problem.upper) - Math.max(groupA2.lower, problem.lower))\n val diffB = groupB2.upper - groupB2.lower + 1 -\n Math.max(0, Math.min(groupB2.upper, problem.upper) - Math.max(groupB2.lower, problem.lower))\n\n if (diffA < diffB) {\n groupA2 = Problem(Math.max(groupA2.lower, problem.lower), Math.min(groupA2.upper, problem.upper))\n } else {\n groupB2 = Problem(Math.max(groupB2.lower, problem.lower), Math.min(groupB2.upper, problem.upper))\n }\n }\n\n\n val answer = Math.min(\n Math.max(0, groupA.upper - groupA.lower + 1) + Math.max(0, groupB.upper - groupB.lower + 1),\n Math.max(0, groupA2.upper - groupA2.lower + 1) + Math.max(0, groupB2.upper - groupB2.lower + 1)\n )\n\n println(answer)\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "sample_input": "4\n4 7\n1 4\n5 8\n2 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02874", "source_text": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2072, "cpu_time_ms": 894, "memory_kb": 81212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s760060698", "group_id": "codeNet:p02874", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var lrList = (1..n).map {\n val (l, r) = readLine()!!.split(\" \").map(String::toLong)\n Pair(l, r)\n }\n lrList = lrList.sortedBy{ it.second }\n lrList = lrList.sortedBy { it.first }\n\n val leftSecondMinMap = Array(n) { lrList.first().second }\n val rightSecondMinMap = Array(n) { lrList.last().second }\n (1 until n).forEach { leftSecondMinMap[it] = Math.min(lrList[it].second, leftSecondMinMap[it - 1]) }\n (n - 2 downTo 0).forEach { rightSecondMinMap[it] = Math.min(lrList[it].second, rightSecondMinMap[it + 1]) }\n\n var maxScore = 0L\n for (i in 0 until n - 1) {\n val s1 = Math.max(0, leftSecondMinMap[i] - lrList[i].first + 1)\n val s2 = Math.max(0, rightSecondMinMap[i + 1] - lrList.last().first + 1)\n maxScore = Math.max(maxScore, s1 + s2)\n }\n println(maxScore)\n}", "language": "Kotlin", "metadata": {"date": 1572847958, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02874.html", "problem_id": "p02874", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02874/input.txt", "sample_output_relpath": "derived/input_output/data/p02874/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02874/Kotlin/s760060698.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s760060698", "user_id": "u099066216"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var lrList = (1..n).map {\n val (l, r) = readLine()!!.split(\" \").map(String::toLong)\n Pair(l, r)\n }\n lrList = lrList.sortedBy{ it.second }\n lrList = lrList.sortedBy { it.first }\n\n val leftSecondMinMap = Array(n) { lrList.first().second }\n val rightSecondMinMap = Array(n) { lrList.last().second }\n (1 until n).forEach { leftSecondMinMap[it] = Math.min(lrList[it].second, leftSecondMinMap[it - 1]) }\n (n - 2 downTo 0).forEach { rightSecondMinMap[it] = Math.min(lrList[it].second, rightSecondMinMap[it + 1]) }\n\n var maxScore = 0L\n for (i in 0 until n - 1) {\n val s1 = Math.max(0, leftSecondMinMap[i] - lrList[i].first + 1)\n val s2 = Math.max(0, rightSecondMinMap[i + 1] - lrList.last().first + 1)\n maxScore = Math.max(maxScore, s1 + s2)\n }\n println(maxScore)\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "sample_input": "4\n4 7\n1 4\n5 8\n2 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02874", "source_text": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 894, "cpu_time_ms": 1123, "memory_kb": 87020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s312911942", "group_id": "codeNet:p02880", "input_text": "fun main(a:Array){val r=readLine()!!.toInt()\nfor(i in 1..9){for(j in 1..9){if(r==i*j){println(\"Yes\");System.exit(0)}}}\nprintln(\"No\")}", "language": "Kotlin", "metadata": {"date": 1572908784, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Kotlin/s312911942.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312911942", "user_id": "u370564845"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(a:Array){val r=readLine()!!.toInt()\nfor(i in 1..9){for(j in 1..9){if(r==i*j){println(\"Yes\");System.exit(0)}}}\nprintln(\"No\")}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 207, "memory_kb": 33604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s720300718", "group_id": "codeNet:p02880", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var ans = \"No\"\n for (a in 1..9) {\n for (b in 1..9) {\n if (a * b == n) {\n ans = \"Yes\"\n }\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1572224619, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Kotlin/s720300718.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s720300718", "user_id": "u863309603"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var ans = \"No\"\n for (a in 1..9) {\n for (b in 1..9) {\n if (a * b == n) {\n ans = \"Yes\"\n }\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 239, "cpu_time_ms": 244, "memory_kb": 31752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s959318712", "group_id": "codeNet:p02883", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').let {\n it[0].toInt() to it[1].toLong()\n }\n val a = readLine()!!.split(' ').map { it.toInt() }.sorted().toIntArray()\n val f = readLine()!!.split(' ').map { it.toInt() }.sortedDescending().toIntArray()\n\n var l = 0L\n var r = 1e12.toLong()\n while (l < r) {\n val m = l + (r - l) / 2\n\n var x = 0L\n for (i in 0 until n) {\n x += Math.max(a[i] - (m / f[i]), 0)\n }\n\n if (x <= k) {\n r = m\n } else {\n l = m + 1\n }\n }\n\n println(l)\n}\n", "language": "Kotlin", "metadata": {"date": 1590627396, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02883.html", "problem_id": "p02883", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02883/input.txt", "sample_output_relpath": "derived/input_output/data/p02883/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02883/Kotlin/s959318712.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959318712", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(' ').let {\n it[0].toInt() to it[1].toLong()\n }\n val a = readLine()!!.split(' ').map { it.toInt() }.sorted().toIntArray()\n val f = readLine()!!.split(' ').map { it.toInt() }.sortedDescending().toIntArray()\n\n var l = 0L\n var r = 1e12.toLong()\n while (l < r) {\n val m = l + (r - l) / 2\n\n var x = 0L\n for (i in 0 until n) {\n x += Math.max(a[i] - (m / f[i]), 0)\n }\n\n if (x <= k) {\n r = m\n } else {\n l = m + 1\n }\n }\n\n println(l)\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "sample_input": "3 5\n4 2 1\n2 3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02883", "source_text": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 606, "cpu_time_ms": 1572, "memory_kb": 113928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s946745869", "group_id": "codeNet:p02886", "input_text": "fun main (args : Array) {\n\tval n = readLine()\n\tval l = readLine()!!.split(\" \")\n\tvar list : MutableList = mutableListOf()\n\tvar result : Int = 0\n\tfor (i in l) {\n\t\tlist.add(i.toInt())\n\t}\n\tfor (i in 0..list.size - 2) {\n\t\tfor (j in i + 1..list.size - 1) {\n\t\t\tresult += (list[i] * list[j])\n\t\t}\n\t}\n\tprintln(\"${result}\")\n}", "language": "Kotlin", "metadata": {"date": 1572290142, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02886/input.txt", "sample_output_relpath": "derived/input_output/data/p02886/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02886/Kotlin/s946745869.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946745869", "user_id": "u651257341"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "fun main (args : Array) {\n\tval n = readLine()\n\tval l = readLine()!!.split(\" \")\n\tvar list : MutableList = mutableListOf()\n\tvar result : Int = 0\n\tfor (i in l) {\n\t\tlist.add(i.toInt())\n\t}\n\tfor (i in 0..list.size - 2) {\n\t\tfor (j in i + 1..list.size - 1) {\n\t\t\tresult += (list[i] * list[j])\n\t\t}\n\t}\n\tprintln(\"${result}\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "sample_input": "3\n3 1 2\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02886", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 237, "memory_kb": 37816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s287031507", "group_id": "codeNet:p02886", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Long, d: LongArray){\n val sa = d.sum()\n val sb = d.map{it*it}.sum()\n println((sa * sa - sb)/2)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toLong()\n val d = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n d[i] = sc.next().toLong()\n }\n solve(N, d)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1571691149, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02886/input.txt", "sample_output_relpath": "derived/input_output/data/p02886/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02886/Kotlin/s287031507.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s287031507", "user_id": "u329232967"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Long, d: LongArray){\n val sa = d.sum()\n val sb = d.map{it*it}.sum()\n println((sa * sa - sb)/2)\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toLong()\n val d = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n d[i] = sc.next().toLong()\n }\n solve(N, d)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "sample_input": "3\n3 1 2\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02886", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 862, "cpu_time_ms": 211, "memory_kb": 32292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s948961720", "group_id": "codeNet:p02886", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n var sum = 0L\n for (x in 0 until n - 1) {\n for (y in x + 1 until n) {\n sum += dList[x] * dList[y]\n }\n }\n println(sum)\n}\n", "language": "Kotlin", "metadata": {"date": 1571533979, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02886/input.txt", "sample_output_relpath": "derived/input_output/data/p02886/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02886/Kotlin/s948961720.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948961720", "user_id": "u979004569"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val dList = readLine()!!.split(\" \").map { it.toInt() }\n var sum = 0L\n for (x in 0 until n - 1) {\n for (y in x + 1 until n) {\n sum += dList[x] * dList[y]\n }\n }\n println(sum)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "sample_input": "3\n3 1 2\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02886", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 277, "memory_kb": 35948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s274684258", "group_id": "codeNet:p02887", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val S :List = readLine()!!.split(\"\")\n .filter{it != \"\"}\n println(wei(S)+1)\n\n}\n\nfun wei(list :List,c :Int = 0) : Int {\n if (list.size === 1) {\n return c\n }\n \n return if (list[0] == list[1]) {\n wei(list.slice(1..list.size-1), c)\n } else {\n wei(list.slice(1..list.size-1), c + 1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1571978027, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s274684258.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s274684258", "user_id": "u951980350"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val S :List = readLine()!!.split(\"\")\n .filter{it != \"\"}\n println(wei(S)+1)\n\n}\n\nfun wei(list :List,c :Int = 0) : Int {\n if (list.size === 1) {\n return c\n }\n \n return if (list[0] == list[1]) {\n wei(list.slice(1..list.size-1), c)\n } else {\n wei(list.slice(1..list.size-1), c + 1)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 2119, "memory_kb": 295352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s885697998", "group_id": "codeNet:p02887", "input_text": "\nfun main(args: Array) {\n readLine()\n val inp = readLine()!!\n var hist = \"\"\n var ans = 0\n inp.forEach {\n if(it.toString() != hist) ans++\n hist = it.toString()\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1571533810, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s885697998.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s885697998", "user_id": "u730905004"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nfun main(args: Array) {\n readLine()\n val inp = readLine()!!\n var hist = \"\"\n var ans = 0\n inp.forEach {\n if(it.toString() != hist) ans++\n hist = it.toString()\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 262, "memory_kb": 37576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s718109986", "group_id": "codeNet:p02887", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n var count = 1\n for(i in 1 until s.length) {\n if (s[i - 1] != s[i]) {\n count++\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1571533583, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s718109986.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718109986", "user_id": "u719622470"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n var count = 1\n for(i in 1 until s.length) {\n if (s[i - 1] != s[i]) {\n count++\n }\n }\n println(count)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 288, "memory_kb": 34324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285456524", "group_id": "codeNet:p02887", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val S = readInputLine().toCharArray()\n \n var ans = 1\n \n for (i in 1 until N) {\n if (S[i - 1] != S[i]) {\n ans++\n }\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1571533527, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Kotlin/s285456524.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285456524", "user_id": "u505558493"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val S = readInputLine().toCharArray()\n \n var ans = 1\n \n for (i in 1 until N) {\n if (S[i - 1] != S[i]) {\n ans++\n }\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 234, "memory_kb": 33892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s319839415", "group_id": "codeNet:p02888", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val L = readLine()!!.split(\" \").map {it.toInt()}.sorted()\n\n var res = 0L\n\n for (i in L.indices) for (j in i + 1 until L.size) {\n val l = Math.abs(L[i] - L[j])\n val u = L[i] + L[j]\n\n val a = Math.max(upperBound(L, l), j + 1)\n val b = lowerBound(L, u)\n\n if (b < a) {\n continue\n }\n\n res += (b - a)\n\n if (i in a until b) {\n res -= 1L\n }\n if (j in a until b) {\n res -= 1L\n }\n }\n\n println(res)\n}\n\nprivate fun lowerBound(list: List, v: Int): Int {\n if (list.last() < v) {\n return list.size\n }\n\n var l = -1\n var u = list.size - 1\n\n while (u - l > 1) {\n val c = (u + l) / 2\n if (list[c] >= v) {\n u = c\n } else {\n l = c\n }\n }\n\n return u\n}\n\nprivate fun upperBound(list: List, v: Int): Int {\n var l = 0\n var u = list.size\n\n while (u - l > 1) {\n val c = (u + l) / 2\n if (list[c] > v) {\n u = c\n } else {\n l = c\n }\n }\n\n return u\n}\n", "language": "Kotlin", "metadata": {"date": 1577128116, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s319839415.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s319839415", "user_id": "u183530284"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val L = readLine()!!.split(\" \").map {it.toInt()}.sorted()\n\n var res = 0L\n\n for (i in L.indices) for (j in i + 1 until L.size) {\n val l = Math.abs(L[i] - L[j])\n val u = L[i] + L[j]\n\n val a = Math.max(upperBound(L, l), j + 1)\n val b = lowerBound(L, u)\n\n if (b < a) {\n continue\n }\n\n res += (b - a)\n\n if (i in a until b) {\n res -= 1L\n }\n if (j in a until b) {\n res -= 1L\n }\n }\n\n println(res)\n}\n\nprivate fun lowerBound(list: List, v: Int): Int {\n if (list.last() < v) {\n return list.size\n }\n\n var l = -1\n var u = list.size - 1\n\n while (u - l > 1) {\n val c = (u + l) / 2\n if (list[c] >= v) {\n u = c\n } else {\n l = c\n }\n }\n\n return u\n}\n\nprivate fun upperBound(list: List, v: Int): Int {\n var l = 0\n var u = list.size\n\n while (u - l > 1) {\n val c = (u + l) / 2\n if (list[c] > v) {\n u = c\n } else {\n l = c\n }\n }\n\n return u\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1180, "cpu_time_ms": 540, "memory_kb": 41004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s402221734", "group_id": "codeNet:p02888", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(' ').map { it.toInt() }.sorted()\n\n var ans = 0\n\n for (i in 0 until n - 2) {\n val a = xs[i]\n for (j in i + 1 until n - 1) {\n val b = xs[j]\n\n ans += xs.binarySearch(a + b, Comparator { o1, o2 -> if (o1 >= o2) 1 else -1 }, j + 1)\n .let { -(it + 1) - 1 }\n .let { it - j }\n }\n }\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1571641282, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s402221734.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402221734", "user_id": "u863309603"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(' ').map { it.toInt() }.sorted()\n\n var ans = 0\n\n for (i in 0 until n - 2) {\n val a = xs[i]\n for (j in i + 1 until n - 1) {\n val b = xs[j]\n\n ans += xs.binarySearch(a + b, Comparator { o1, o2 -> if (o1 >= o2) 1 else -1 }, j + 1)\n .let { -(it + 1) - 1 }\n .let { it - j }\n }\n }\n\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 501, "cpu_time_ms": 406, "memory_kb": 45268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s546667913", "group_id": "codeNet:p02888", "input_text": "fun main(args: Array) {\n abc143d()\n}\n\nfun abc143d() {\n val n = readLine()!!.toInt()\n val lines = readLine()!!.split(\" \").map { it.toInt() }\n .sorted().toIntArray()\n\n var answer = 0\n for (ai in 0..lines.size - 2) {\n for (bi in ai + 1..lines.size - 1) {\n val right = lowerBound(lines, lines[ai] + lines[bi])\n val left = bi + 1\n answer += right - left\n }\n }\n\n println(answer)\n}\n\n// list must be sorted\n// find element's index, greater than or equals key\nprivate fun lowerBound(list: IntArray, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] >= key) ok = mid else ng = mid\n }\n return ok\n}\n", "language": "Kotlin", "metadata": {"date": 1571543462, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s546667913.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s546667913", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n abc143d()\n}\n\nfun abc143d() {\n val n = readLine()!!.toInt()\n val lines = readLine()!!.split(\" \").map { it.toInt() }\n .sorted().toIntArray()\n\n var answer = 0\n for (ai in 0..lines.size - 2) {\n for (bi in ai + 1..lines.size - 1) {\n val right = lowerBound(lines, lines[ai] + lines[bi])\n val left = bi + 1\n answer += right - left\n }\n }\n\n println(answer)\n}\n\n// list must be sorted\n// find element's index, greater than or equals key\nprivate fun lowerBound(list: IntArray, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] >= key) ok = mid else ng = mid\n }\n return ok\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 763, "cpu_time_ms": 391, "memory_kb": 37996}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s512150650", "group_id": "codeNet:p02888", "input_text": "import java.lang.Math\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map(String::toInt).sorted()\n\n var result = 0\n\n for (i in 0 until n) {\n val l1 = l[i]\n for (j in i + 1 until n) {\n val l2 = l[j]\n val min = Math.abs(l1 - l2) + 1\n val max = l1 + l2 - 1\n\n result += l.slice(j + 1 until n).indexOfFirst { it !in min..max }.let {\n if (it < 0) n - (j + 1) else it\n }\n }\n }\n\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1571536193, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/Kotlin/s512150650.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s512150650", "user_id": "u379804877"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.lang.Math\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val l = readLine()!!.split(\" \").map(String::toInt).sorted()\n\n var result = 0\n\n for (i in 0 until n) {\n val l1 = l[i]\n for (j in i + 1 until n) {\n val l2 = l[j]\n val min = Math.abs(l1 - l2) + 1\n val max = l1 + l2 - 1\n\n result += l.slice(j + 1 until n).indexOfFirst { it !in min..max }.let {\n if (it < 0) n - (j + 1) else it\n }\n }\n }\n\n println(result)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 547, "cpu_time_ms": 2111, "memory_kb": 120284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s160340886", "group_id": "codeNet:p02897", "input_text": "fun main(args: Array) {\n sandbox4()\n}\n\nfun sandbox4() {\n val n = readLine()!!.toInt()\n\n val answer = (1..n).count { it % 2 != 0 } / n.toDouble()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1574033003, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02897.html", "problem_id": "p02897", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02897/input.txt", "sample_output_relpath": "derived/input_output/data/p02897/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02897/Kotlin/s160340886.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160340886", "user_id": "u139478771"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "fun main(args: Array) {\n sandbox4()\n}\n\nfun sandbox4() {\n val n = readLine()!!.toInt()\n\n val answer = (1..n).count { it % 2 != 0 } / n.toDouble()\n\n println(answer)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "sample_input": "4\n"}, "reference_outputs": ["0.5000000000\n"], "source_document_id": "p02897", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 208, "memory_kb": 31708}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s262308220", "group_id": "codeNet:p02898", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val h = readLine()!!.split(\" \").map(String::toInt)\n\n println(op142b(k, h))\n}\n\n\nfun op142b(limit: Int, member: List) = member.filter { it >= limit }.count()\n", "language": "Kotlin", "metadata": {"date": 1570395396, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02898/input.txt", "sample_output_relpath": "derived/input_output/data/p02898/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02898/Kotlin/s262308220.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s262308220", "user_id": "u185193033"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val h = readLine()!!.split(\" \").map(String::toInt)\n\n println(op142b(k, h))\n}\n\n\nfun op142b(limit: Int, member: List) = member.filter { it >= limit }.count()\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "sample_input": "4 150\n150 140 100 200\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02898", "source_text": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 481, "memory_kb": 46316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s159552170", "group_id": "codeNet:p02898", "input_text": "fun main(args: Array) {\n abc142b()\n}\n\nfun abc142b() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val hList = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = hList.filter { it >= k }\n\n println(answer.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1569719035, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02898/input.txt", "sample_output_relpath": "derived/input_output/data/p02898/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02898/Kotlin/s159552170.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159552170", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n abc142b()\n}\n\nfun abc142b() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val hList = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = hList.filter { it >= k }\n\n println(answer.size)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "sample_input": "4 150\n150 140 100 200\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02898", "source_text": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 482, "memory_kb": 48128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s279451668", "group_id": "codeNet:p02900", "input_text": "import java.util.*\n\ntailrec fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)\n\nfun factorize(n: Long): List> {\n val list = ArrayList>()\n var m = n\n var k = 2L\n\n while (m > 1 && k * k <= m) {\n var s = 0L\n while (m % k == 0L) {\n m /= k\n s++\n }\n if (s > 0) {\n list.add(Pair(k, s))\n }\n k++\n }\n\n if (m > 1) {\n list.add(Pair(m, 1L))\n }\n\n return list\n}\n\nfun main(args: Array) {\n val (A, B) = readLine()!!.split(\" \").map{it.toLong()}\n val g = gcd(A, B)\n\n println(factorize(g).size + 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1573704787, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02900/input.txt", "sample_output_relpath": "derived/input_output/data/p02900/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02900/Kotlin/s279451668.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s279451668", "user_id": "u183530284"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\ntailrec fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)\n\nfun factorize(n: Long): List> {\n val list = ArrayList>()\n var m = n\n var k = 2L\n\n while (m > 1 && k * k <= m) {\n var s = 0L\n while (m % k == 0L) {\n m /= k\n s++\n }\n if (s > 0) {\n list.add(Pair(k, s))\n }\n k++\n }\n\n if (m > 1) {\n list.add(Pair(m, 1L))\n }\n\n return list\n}\n\nfun main(args: Array) {\n val (A, B) = readLine()!!.split(\" \").map{it.toLong()}\n val g = gcd(A, B)\n\n println(factorize(g).size + 1)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 655, "cpu_time_ms": 245, "memory_kb": 37988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s245060597", "group_id": "codeNet:p02900", "input_text": "import java.util.*\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n val a = scanner.nextLong()\n val b = scanner.nextLong()\n if (a == 1L || b == 1L) {\n println(1)\n } else {\n var count = 1\n val min = if (a < b) a else b\n val list = mutableListOf()\n loop@for (i in 2..min) {\n if (a % i != 0L) continue\n if (b % i != 0L) continue\n var flag = true\n list.forEach {\n if (i % it == 0L) {\n flag = false\n return@forEach\n }\n }\n if (flag) {\n list.add(i)\n count += 1\n }\n }\n println(count)\n }\n}", "language": "Kotlin", "metadata": {"date": 1569723189, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02900/input.txt", "sample_output_relpath": "derived/input_output/data/p02900/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02900/Kotlin/s245060597.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s245060597", "user_id": "u080175484"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n val scanner = Scanner(System.`in`)\n val a = scanner.nextLong()\n val b = scanner.nextLong()\n if (a == 1L || b == 1L) {\n println(1)\n } else {\n var count = 1\n val min = if (a < b) a else b\n val list = mutableListOf()\n loop@for (i in 2..min) {\n if (a % i != 0L) continue\n if (b % i != 0L) continue\n var flag = true\n list.forEach {\n if (i % it == 0L) {\n flag = false\n return@forEach\n }\n }\n if (flag) {\n list.add(i)\n count += 1\n }\n }\n println(count)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 750, "cpu_time_ms": 2111, "memory_kb": 31648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s478665129", "group_id": "codeNet:p02905", "input_text": "import java.util.*\n\nfun main(omkar: Array) {\n val n = readLine()!!.toInt()\n val tokenizer = StringTokenizer(readLine()!!)\n val array = IntArray(n) { tokenizer.nextToken().toInt() }\n val primes = Array(1000001) { mutableListOf() }\n for (p in 2..1000000) {\n if (primes[p].isEmpty()) {\n var k = p\n while (k <= 1000000) {\n primes[k].add(p)\n k += p\n }\n }\n }\n val sums = LongArray(1000001)\n for (k in array) {\n val kl = k.toLong()\n fun recur(d: Int) {\n if (primes[k].isEmpty()) {\n sums[d] += kl\n } else {\n val p = primes[k].removeAt(primes[k].size - 1)\n var dn = d\n recur(dn)\n while ((k / dn) % p == 0) {\n dn *= p\n recur(dn)\n }\n primes[k].add(p)\n }\n }\n recur(1)\n }\n val reciprocal = LongArray(1000001)\n reciprocal[1] = 1L\n val dp = LongArray(1000001)\n dp[1] = 1L\n for (k in 2..1000000) {\n val p = primes[k][0]\n if (k == p) {\n reciprocal[k] = k.toLong() pow -1\n } else {\n reciprocal[k] = (reciprocal[p] * reciprocal[k / p]) % MOD\n }\n if (primes[k].size == 1) {\n dp[k] = reciprocal[k] - reciprocal[k / primes[k][0]]\n } else {\n var power = 1\n while ((k / power) % p == 0) {\n power *= p\n }\n dp[k] = dp[power] * dp[k / power]\n dp[k] %= MOD\n }\n sums[k] *= dp[k]\n sums[k] %= MOD\n }\n var answer = 0L\n for (k in array) {\n val kl = k.toLong()\n answer -= kl\n fun recur(d: Int) {\n if (primes[k].isEmpty()) {\n answer += kl * sums[d]\n } else {\n val p = primes[k].removeAt(primes[k].size - 1)\n var dn = d\n recur(dn)\n while ((k / dn) % p == 0) {\n dn *= p\n recur(dn)\n }\n primes[k].add(p)\n }\n }\n recur(1)\n answer %= MOD\n }\n answer *= reciprocal[2]\n answer %= MOD\n answer += MOD\n answer %= MOD\n println(answer)\n}\n\nval MOD: Long = 998244353\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "language": "Kotlin", "metadata": {"date": 1583746698, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02905.html", "problem_id": "p02905", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02905/input.txt", "sample_output_relpath": "derived/input_output/data/p02905/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02905/Kotlin/s478665129.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s478665129", "user_id": "u590243733"}, "prompt_components": {"gold_output": "22\n", "input_to_evaluate": "import java.util.*\n\nfun main(omkar: Array) {\n val n = readLine()!!.toInt()\n val tokenizer = StringTokenizer(readLine()!!)\n val array = IntArray(n) { tokenizer.nextToken().toInt() }\n val primes = Array(1000001) { mutableListOf() }\n for (p in 2..1000000) {\n if (primes[p].isEmpty()) {\n var k = p\n while (k <= 1000000) {\n primes[k].add(p)\n k += p\n }\n }\n }\n val sums = LongArray(1000001)\n for (k in array) {\n val kl = k.toLong()\n fun recur(d: Int) {\n if (primes[k].isEmpty()) {\n sums[d] += kl\n } else {\n val p = primes[k].removeAt(primes[k].size - 1)\n var dn = d\n recur(dn)\n while ((k / dn) % p == 0) {\n dn *= p\n recur(dn)\n }\n primes[k].add(p)\n }\n }\n recur(1)\n }\n val reciprocal = LongArray(1000001)\n reciprocal[1] = 1L\n val dp = LongArray(1000001)\n dp[1] = 1L\n for (k in 2..1000000) {\n val p = primes[k][0]\n if (k == p) {\n reciprocal[k] = k.toLong() pow -1\n } else {\n reciprocal[k] = (reciprocal[p] * reciprocal[k / p]) % MOD\n }\n if (primes[k].size == 1) {\n dp[k] = reciprocal[k] - reciprocal[k / primes[k][0]]\n } else {\n var power = 1\n while ((k / power) % p == 0) {\n power *= p\n }\n dp[k] = dp[power] * dp[k / power]\n dp[k] %= MOD\n }\n sums[k] *= dp[k]\n sums[k] %= MOD\n }\n var answer = 0L\n for (k in array) {\n val kl = k.toLong()\n answer -= kl\n fun recur(d: Int) {\n if (primes[k].isEmpty()) {\n answer += kl * sums[d]\n } else {\n val p = primes[k].removeAt(primes[k].size - 1)\n var dn = d\n recur(dn)\n while ((k / dn) % p == 0) {\n dn *= p\n recur(dn)\n }\n primes[k].add(p)\n }\n }\n recur(1)\n answer %= MOD\n }\n answer *= reciprocal[2]\n answer %= MOD\n answer += MOD\n answer %= MOD\n println(answer)\n}\n\nval MOD: Long = 998244353\nval MOD_TOTIENT = (MOD - 1).toInt()\n\ninfix fun Long.pow(power: Int): Long {\n var e = power\n e %= MOD_TOTIENT\n if (e < 0) {\n e += MOD_TOTIENT\n }\n if (e == 0 && this == 0L) {\n return this\n }\n var b = this\n var res = 1L\n while (e > 0) {\n if (e and 1 != 0) {\n res *= b\n res %= MOD\n }\n b *= b\n b %= MOD\n e = e shr 1\n }\n return res\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have an integer sequence of length N: A_0,A_1,\\cdots,A_{N-1}.\n\nFind the following sum (\\mathrm{lcm}(a, b) denotes the least common multiple of a and b):\n\n\\sum_{i=0}^{N-2} \\sum_{j=i+1}^{N-1} \\mathrm{lcm}(A_i,A_j)\n\nSince the answer may be enormous, compute it modulo 998244353.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 1000000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0\\ A_1\\ \\cdots\\ A_{N-1}\n\nOutput\n\nPrint the sum modulo 998244353.\n\nSample Input 1\n\n3\n2 4 6\n\nSample Output 1\n\n22\n\n\\mathrm{lcm}(2,4)+\\mathrm{lcm}(2,6)+\\mathrm{lcm}(4,6)=4+6+12=22.\n\nSample Input 2\n\n8\n1 2 3 4 6 8 12 12\n\nSample Output 2\n\n313\n\nSample Input 3\n\n10\n356822 296174 484500 710640 518322 888250 259161 609120 592348 713644\n\nSample Output 3\n\n353891724", "sample_input": "3\n2 4 6\n"}, "reference_outputs": ["22\n"], "source_document_id": "p02905", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have an integer sequence of length N: A_0,A_1,\\cdots,A_{N-1}.\n\nFind the following sum (\\mathrm{lcm}(a, b) denotes the least common multiple of a and b):\n\n\\sum_{i=0}^{N-2} \\sum_{j=i+1}^{N-1} \\mathrm{lcm}(A_i,A_j)\n\nSince the answer may be enormous, compute it modulo 998244353.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 1000000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0\\ A_1\\ \\cdots\\ A_{N-1}\n\nOutput\n\nPrint the sum modulo 998244353.\n\nSample Input 1\n\n3\n2 4 6\n\nSample Output 1\n\n22\n\n\\mathrm{lcm}(2,4)+\\mathrm{lcm}(2,6)+\\mathrm{lcm}(4,6)=4+6+12=22.\n\nSample Input 2\n\n8\n1 2 3 4 6 8 12 12\n\nSample Output 2\n\n313\n\nSample Input 3\n\n10\n356822 296174 484500 710640 518322 888250 259161 609120 592348 713644\n\nSample Output 3\n\n353891724", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2793, "cpu_time_ms": 2111, "memory_kb": 222324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s102401441", "group_id": "codeNet:p02909", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val s = next()\n\n when (s) {\n \"Sunny\" -> println(\"Cloudy\")\n \"Cloudy\" -> println(\"Rainy\")\n \"Rainy\" -> println(\"Sunny\")\n }\n}\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1590229893, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02909/input.txt", "sample_output_relpath": "derived/input_output/data/p02909/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02909/Kotlin/s102401441.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s102401441", "user_id": "u581625805"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val s = next()\n\n when (s) {\n \"Sunny\" -> println(\"Cloudy\")\n \"Cloudy\" -> println(\"Rainy\")\n \"Rainy\" -> println(\"Sunny\")\n }\n}\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 17688, "cpu_time_ms": 172, "memory_kb": 29472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s689071182", "group_id": "codeNet:p02909", "input_text": "fun main(args: Array) {\n val w = readLine()!!\n when (w) {\n \"Sunny\" -> println(\"Cloudy\")\n \"Cloudy\" -> println(\"Rainy\")\n else -> println(\"Sunny\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1574079109, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02909/input.txt", "sample_output_relpath": "derived/input_output/data/p02909/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02909/Kotlin/s689071182.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s689071182", "user_id": "u396701320"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "fun main(args: Array) {\n val w = readLine()!!\n when (w) {\n \"Sunny\" -> println(\"Cloudy\")\n \"Cloudy\" -> println(\"Rainy\")\n else -> println(\"Sunny\")\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 197, "memory_kb": 29864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s623235777", "group_id": "codeNet:p02909", "input_text": "fun main(args: Array) {\n val n = readLine()!!\n\n println(op141a(n))\n}\n\nfun op141a(n: String): String {\n val weather = mutableListOf(\"Sunny\",\"Cloudy\",\"Rainy\")\n val index = if (weather.indexOf(n) == weather.size) 0 else weather.indexOf(n) + 1\n return weather[index]\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1570414008, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02909/input.txt", "sample_output_relpath": "derived/input_output/data/p02909/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02909/Kotlin/s623235777.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s623235777", "user_id": "u185193033"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!\n\n println(op141a(n))\n}\n\nfun op141a(n: String): String {\n val weather = mutableListOf(\"Sunny\",\"Cloudy\",\"Rainy\")\n val index = if (weather.indexOf(n) == weather.size) 0 else weather.indexOf(n) + 1\n return weather[index]\n}\n\n\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 290, "cpu_time_ms": 203, "memory_kb": 33532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s267767312", "group_id": "codeNet:p02909", "input_text": "fun main() {\n val s = readLine()!!\n\n val r = when (s) {\n \"Sunny\" -> \"Cloudy\"\n \"Cloudy\" -> \"Rainy\"\n \"Rainy\" -> \"Sunny\"\n else -> \"\"\n }\n\n println(r)\n}", "language": "Kotlin", "metadata": {"date": 1569510541, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02909/input.txt", "sample_output_relpath": "derived/input_output/data/p02909/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02909/Kotlin/s267767312.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s267767312", "user_id": "u379804877"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!\n\n val r = when (s) {\n \"Sunny\" -> \"Cloudy\"\n \"Cloudy\" -> \"Rainy\"\n \"Rainy\" -> \"Sunny\"\n else -> \"\"\n }\n\n println(r)\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 187, "cpu_time_ms": 183, "memory_kb": 29344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s900867862", "group_id": "codeNet:p02910", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n for (i in 1..s.length) {\n if ((i % 2 == 1 && s[i-1] == 'L') || (i % 2 == 0 && s[i-1] == 'R')) {\n println(\"No\")\n System.exit(0)\n }\n }\n println(\"Yes\")\n}", "language": "Kotlin", "metadata": {"date": 1574212618, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02910.html", "problem_id": "p02910", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02910/input.txt", "sample_output_relpath": "derived/input_output/data/p02910/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02910/Kotlin/s900867862.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s900867862", "user_id": "u396701320"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n for (i in 1..s.length) {\n if ((i % 2 == 1 && s[i-1] == 'L') || (i % 2 == 0 && s[i-1] == 'R')) {\n println(\"No\")\n System.exit(0)\n }\n }\n println(\"Yes\")\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "sample_input": "RUDLUDR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02910", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 202, "memory_kb": 31768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s752549695", "group_id": "codeNet:p02911", "input_text": "fun main(args:Array) {\n val (n,k,q) = readLine()!!.split(\" \").map { it.toLong() }\n val log = (1..q).map { readLine()!!.toInt()-1 }\n val ans = (1..n).map { k - q }.toMutableList()\n for(i in log) {\n ans[i] = ans[i] + 1\n }\n for(i in ans) {\n println(if(i>0) \"Yes\" else \"No\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1591961394, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02911/input.txt", "sample_output_relpath": "derived/input_output/data/p02911/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02911/Kotlin/s752549695.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s752549695", "user_id": "u269969976"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "fun main(args:Array) {\n val (n,k,q) = readLine()!!.split(\" \").map { it.toLong() }\n val log = (1..q).map { readLine()!!.toInt()-1 }\n val ans = (1..n).map { k - q }.toMutableList()\n for(i in log) {\n ans[i] = ans[i] + 1\n }\n for(i in ans) {\n println(if(i>0) \"Yes\" else \"No\")\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 995, "memory_kb": 52336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s004972272", "group_id": "codeNet:p02911", "input_text": "fun main(args: Array) {\n val (N, K, Q) = listOfInt()\n val A = Array(Q) { nextInt(-1) }\n val W = Array(N) { Q }\n A.forEach { W[it] -= 1 }\n W.forEach { println(if (K - it > 0) \"Yes\" else \"No\") }\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }", "language": "Kotlin", "metadata": {"date": 1568597156, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02911/input.txt", "sample_output_relpath": "derived/input_output/data/p02911/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02911/Kotlin/s004972272.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004972272", "user_id": "u043150661"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K, Q) = listOfInt()\n val A = Array(Q) { nextInt(-1) }\n val W = Array(N) { Q }\n A.forEach { W[it] -= 1 }\n W.forEach { println(if (K - it > 0) \"Yes\" else \"No\") }\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 439, "cpu_time_ms": 965, "memory_kb": 48236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s466140637", "group_id": "codeNet:p02915", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n\n println(n*n*n)\n}", "language": "Kotlin", "metadata": {"date": 1567904603, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/Kotlin/s466140637.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466140637", "user_id": "u153537680"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n\n println(n*n*n)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 142, "cpu_time_ms": 181, "memory_kb": 29468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s523126152", "group_id": "codeNet:p02915", "input_text": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n\n println(Math.pow(x.toDouble(), 3.0).toInt())\n\n}", "language": "Kotlin", "metadata": {"date": 1567904484, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/Kotlin/s523126152.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s523126152", "user_id": "u889750959"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n\n println(Math.pow(x.toDouble(), 3.0).toInt())\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 207, "memory_kb": 31788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s439795526", "group_id": "codeNet:p02915", "input_text": "import java.util.*\nimport java.io.PrintWriter\n\n\n\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val cout = PrintWriter(System.`out`)\n val n = cin.nextInt()\n\n cout.println(n*n*n)\n \n cout.flush()\n}\n\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }", "language": "Kotlin", "metadata": {"date": 1567904455, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/Kotlin/s439795526.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439795526", "user_id": "u111421568"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\nimport java.io.PrintWriter\n\n\n\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val cout = PrintWriter(System.`out`)\n val n = cin.nextInt()\n\n cout.println(n*n*n)\n \n cout.flush()\n}\n\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 556, "cpu_time_ms": 196, "memory_kb": 31124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s881244158", "group_id": "codeNet:p02917", "input_text": "import java.lang.Math\n\nfun main(args: Array)\n{\n val (n) = readInts()\n val b = readIntArr()\n\n var sum = b[0] + b[n-2]\n\n for (i in 0..n-3) {\n sum += if (b[i] < b[i+1]) b[i] else b[i+1]\n }\n\n println(sum)\n}\n\nfun readInts(): List = readLine()!!.split(\" \").map(String::toInt)\nfun readLongs(): List = readLine()!!.split(\" \").map(String::toLong)\n\nfun readIntArr(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray()\nfun readLongArr(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray()\n\nfun readIntArrS(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArray()\nfun readLongArrS(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArray()\n\nfun readIntArrSD(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArrayDescending()\nfun readLongArrSD(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArrayDescending()\n\nfun readString() = readLine()!!\n", "language": "Kotlin", "metadata": {"date": 1575506836, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02917/input.txt", "sample_output_relpath": "derived/input_output/data/p02917/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02917/Kotlin/s881244158.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s881244158", "user_id": "u118477733"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.lang.Math\n\nfun main(args: Array)\n{\n val (n) = readInts()\n val b = readIntArr()\n\n var sum = b[0] + b[n-2]\n\n for (i in 0..n-3) {\n sum += if (b[i] < b[i+1]) b[i] else b[i+1]\n }\n\n println(sum)\n}\n\nfun readInts(): List = readLine()!!.split(\" \").map(String::toInt)\nfun readLongs(): List = readLine()!!.split(\" \").map(String::toLong)\n\nfun readIntArr(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray()\nfun readLongArr(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray()\n\nfun readIntArrS(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArray()\nfun readLongArrS(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArray()\n\nfun readIntArrSD(): IntArray = readLine()!!.split(\" \").map(String::toInt).toIntArray().sortedArrayDescending()\nfun readLongArrSD(): LongArray = readLine()!!.split(\" \").map(String::toLong).toLongArray().sortedArrayDescending()\n\nfun readString() = readLine()!!\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "sample_input": "3\n2 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02917", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1022, "cpu_time_ms": 239, "memory_kb": 37908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s207411710", "group_id": "codeNet:p02919", "input_text": "import java.util.*\n\nfun main(args: Array) = IO().exec {\n val n = int()\n val p = IntArray(n){int()-1}\n val indices = IntArray(n)\n for (i in n) indices[p[i]] = i\n val s = TreeSet()\n var ret = 0L\n for (x in (0 until n).reversed()) {\n val i = indices[x]\n s.add(i)\n val l = IntArray(2){-1}\n val r = IntArray(2){n}\n do {\n l[1] = s.lower(i) ?: break\n l[0] = s.lower(l[1]) ?: break\n } while (false)\n do {\n r[0] = s.higher(i) ?: break\n r[1] = s.higher(r[0]) ?: break\n } while (false)\n val ls = IntArray(2)\n val rs = IntArray(2)\n ls[0] = l[1] - l[0]\n ls[1] = i - l[1]\n rs[0] = r[0] - i\n rs[1] = r[1] - r[0]\n ret += (x + 1) * (ls[0].toLong() * rs[0] + ls[1].toLong() * rs[1])\n }\n println(ret)\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n\n inline fun println(block: IO.() -> Any) {\n println(block())\n out.flush()\n }\n}\n// endregion", "language": "Kotlin", "metadata": {"date": 1567901923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/Kotlin/s207411710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207411710", "user_id": "u095834727"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) = IO().exec {\n val n = int()\n val p = IntArray(n){int()-1}\n val indices = IntArray(n)\n for (i in n) indices[p[i]] = i\n val s = TreeSet()\n var ret = 0L\n for (x in (0 until n).reversed()) {\n val i = indices[x]\n s.add(i)\n val l = IntArray(2){-1}\n val r = IntArray(2){n}\n do {\n l[1] = s.lower(i) ?: break\n l[0] = s.lower(l[1]) ?: break\n } while (false)\n do {\n r[0] = s.higher(i) ?: break\n r[1] = s.higher(r[0]) ?: break\n } while (false)\n val ls = IntArray(2)\n val rs = IntArray(2)\n ls[0] = l[1] - l[0]\n ls[1] = i - l[1]\n rs[0] = r[0] - i\n rs[1] = r[1] - r[0]\n ret += (x + 1) * (ls[0].toLong() * rs[0] + ls[1].toLong() * rs[1])\n }\n println(ret)\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n\n inline fun println(block: IO.() -> Any) {\n println(block())\n out.flush()\n }\n}\n// endregion", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3125, "cpu_time_ms": 406, "memory_kb": 46892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s691751198", "group_id": "codeNet:p02919", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val P = readLine()!!.split(\" \").map(String::toInt)\n println(sigoto(P, 0))\n}\n\ntailrec fun sigoto(list: List, sum: Int): Int =\n if(list.size == 2) task(list, sum) else sigoto(list.drop(1), task(list, sum))\n\nfun task(list: List, sum: Int): Int {\n var s = 0\n for (i in 2 until list.size+1) {\n val p = list.take(i).sorted().reversed()\n s += p[1]\n }\n return sum + s\n}", "language": "Kotlin", "metadata": {"date": 1567888751, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/Kotlin/s691751198.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s691751198", "user_id": "u388719350"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val P = readLine()!!.split(\" \").map(String::toInt)\n println(sigoto(P, 0))\n}\n\ntailrec fun sigoto(list: List, sum: Int): Int =\n if(list.size == 2) task(list, sum) else sigoto(list.drop(1), task(list, sum))\n\nfun task(list: List, sum: Int): Int {\n var s = 0\n for (i in 2 until list.size+1) {\n val p = list.take(i).sorted().reversed()\n s += p[1]\n }\n return sum + s\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 2111, "memory_kb": 123304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s886598963", "group_id": "codeNet:p02920", "input_text": "import java.lang.Math\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!.split(\" \").map(String::toInt).sortedDescending()\n\n for (i in 1..(Math.log(s.size.toDouble()) / Math.log(2.0)).toInt()) {\n if (!s.canMultiply(i)) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n}\n\nfun List.canMultiply(n: Int = 1): Boolean {\n val idxBegin = Math.pow(2.0, (n - 1).toDouble()).toInt()\n\n for (i in 0 until idxBegin) {\n if (this[i] <= this[idxBegin + i]) return false\n }\n\n return true\n}", "language": "Kotlin", "metadata": {"date": 1570975332, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02920.html", "problem_id": "p02920", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02920/input.txt", "sample_output_relpath": "derived/input_output/data/p02920/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02920/Kotlin/s886598963.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s886598963", "user_id": "u379804877"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.lang.Math\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!.split(\" \").map(String::toInt).sortedDescending()\n\n for (i in 1..(Math.log(s.size.toDouble()) / Math.log(2.0)).toInt()) {\n if (!s.canMultiply(i)) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n}\n\nfun List.canMultiply(n: Int = 1): Boolean {\n val idxBegin = Math.pow(2.0, (n - 1).toDouble()).toInt()\n\n for (i in 0 until idxBegin) {\n if (this[i] <= this[idxBegin + i]) return false\n }\n\n return true\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have one slime.\n\nYou can set the health of this slime to any integer value of your choice.\n\nA slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen in one second.\n\nDetermine if it is possible to set the healths of our first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals a multiset S.\n\nHere S is a multiset containing 2^N (possibly duplicated) integers: S_1,~S_2,~...,~S_{2^N}.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 18\n\n1 \\leq S_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_{2^N}\n\nOutput\n\nIf it is possible to set the healths of the first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals S, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n4 2 3 1\n\nSample Output 1\n\nYes\n\nWe will show one way to make the multiset of the healths of the slimes that will exist in 2 seconds equal to S.\n\nFirst, set the health of the first slime to 4.\n\nBy letting the first slime spawn a slime whose health is 3, the healths of the slimes that exist in 1 second can be 4,~3.\n\nThen, by letting the first slime spawn a slime whose health is 2, and letting the second slime spawn a slime whose health is 1, the healths of the slimes that exist in 2 seconds can be 4,~3,~2,~1, which is equal to S as multisets.\n\nSample Input 2\n\n2\n1 2 3 1\n\nSample Output 2\n\nYes\n\nS may contain multiple instances of the same integer.\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n5\n4 3 5 3 1 2 7 8 7 4 6 3 7 2 3 6 2 7 3 2 6 7 3 4 6 7 3 4 2 5 2 3\n\nSample Output 4\n\nNo", "sample_input": "2\n4 2 3 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02920", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have one slime.\n\nYou can set the health of this slime to any integer value of your choice.\n\nA slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen in one second.\n\nDetermine if it is possible to set the healths of our first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals a multiset S.\n\nHere S is a multiset containing 2^N (possibly duplicated) integers: S_1,~S_2,~...,~S_{2^N}.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 18\n\n1 \\leq S_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_{2^N}\n\nOutput\n\nIf it is possible to set the healths of the first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals S, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n4 2 3 1\n\nSample Output 1\n\nYes\n\nWe will show one way to make the multiset of the healths of the slimes that will exist in 2 seconds equal to S.\n\nFirst, set the health of the first slime to 4.\n\nBy letting the first slime spawn a slime whose health is 3, the healths of the slimes that exist in 1 second can be 4,~3.\n\nThen, by letting the first slime spawn a slime whose health is 2, and letting the second slime spawn a slime whose health is 1, the healths of the slimes that exist in 2 seconds can be 4,~3,~2,~1, which is equal to S as multisets.\n\nSample Input 2\n\n2\n1 2 3 1\n\nSample Output 2\n\nYes\n\nS may contain multiple instances of the same integer.\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n5\n4 3 5 3 1 2 7 8 7 4 6 3 7 2 3 6 2 7 3 2 6 7 3 4 6 7 3 4 2 5 2 3\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 579, "cpu_time_ms": 849, "memory_kb": 86676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s231452542", "group_id": "codeNet:p02921", "input_text": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n var sum = 0\n for(i in 0 until s.length) {\n if(s[i] === t[i]) {\n sum++\n }\n else {\n\n }\n }\n print(sum)\n}", "language": "Kotlin", "metadata": {"date": 1588245841, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02921/input.txt", "sample_output_relpath": "derived/input_output/data/p02921/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02921/Kotlin/s231452542.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s231452542", "user_id": "u124119858"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!\n val t = readLine()!!\n var sum = 0\n for(i in 0 until s.length) {\n if(s[i] === t[i]) {\n sum++\n }\n else {\n\n }\n }\n print(sum)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 160, "memory_kb": 31128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s180315216", "group_id": "codeNet:p02921", "input_text": "fun main(args : Array) {\n val S = readLine()!!\n val T = readLine()!!\n var count = 0\n (0 until 3).forEach { i ->\n if (S[i] == T[i]) {\n count++\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1567364852, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02921/input.txt", "sample_output_relpath": "derived/input_output/data/p02921/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02921/Kotlin/s180315216.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180315216", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n val S = readLine()!!\n val T = readLine()!!\n var count = 0\n (0 until 3).forEach { i ->\n if (S[i] == T[i]) {\n count++\n }\n }\n println(count)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 214, "memory_kb": 31872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s912757880", "group_id": "codeNet:p02922", "input_text": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`);\n \n while (input.hasNext()) {\n val A = input.nextInt()\n val B = input.nextInt()\n var num = (B - 1) / (A - 1) + if ((B - 1) % (A - 1) > 0) 1 else 0\n \n println(num)\n }\n}", "language": "Kotlin", "metadata": {"date": 1595880104, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02922/input.txt", "sample_output_relpath": "derived/input_output/data/p02922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02922/Kotlin/s912757880.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912757880", "user_id": "u920836104"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\nfun main (args : Array) {\n val input = Scanner(System.`in`);\n \n while (input.hasNext()) {\n val A = input.nextInt()\n val B = input.nextInt()\n var num = (B - 1) / (A - 1) + if ((B - 1) % (A - 1) > 0) 1 else 0\n \n println(num)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "sample_input": "4 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02922", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 124, "memory_kb": 36504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s057596462", "group_id": "codeNet:p02922", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n var r = b\n var c = 1\n r = a\n while (r < b) {\n c++\n r += (a - 1)\n }\n println(c.toString())\n}\n", "language": "Kotlin", "metadata": {"date": 1588709899, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02922/input.txt", "sample_output_relpath": "derived/input_output/data/p02922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02922/Kotlin/s057596462.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057596462", "user_id": "u979429407"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n var r = b\n var c = 1\n r = a\n while (r < b) {\n c++\n r += (a - 1)\n }\n println(c.toString())\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "sample_input": "4 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02922", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 227, "cpu_time_ms": 242, "memory_kb": 37560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s093646852", "group_id": "codeNet:p02923", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val n = Integer.parseInt(readNext())\n val s = readNext().split(\" \").map { Integer.parseInt(it) }\n\n var max = 0\n var nou = 0\n var next = 0\n var tmp = 0\n for (i in 0..n - 1){\n if (i == n-1) {\n\n if ( max >= tmp) {\n\n } else {\n max = tmp\n }\n tmp = 0\n break\n }\n nou = s[i]\n next = s[i + 1]\n if (nou >= next) {\n tmp++\n } else {\n if ( max >= tmp) {\n\n } else {\n max = tmp\n }\n tmp = 0\n }\n }\n println(max)\n}\n\n fun readNext(): String {\n return readLine()!!\n }\n", "language": "Kotlin", "metadata": {"date": 1567453628, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02923/input.txt", "sample_output_relpath": "derived/input_output/data/p02923/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02923/Kotlin/s093646852.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093646852", "user_id": "u376174428"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val n = Integer.parseInt(readNext())\n val s = readNext().split(\" \").map { Integer.parseInt(it) }\n\n var max = 0\n var nou = 0\n var next = 0\n var tmp = 0\n for (i in 0..n - 1){\n if (i == n-1) {\n\n if ( max >= tmp) {\n\n } else {\n max = tmp\n }\n tmp = 0\n break\n }\n nou = s[i]\n next = s[i + 1]\n if (nou >= next) {\n tmp++\n } else {\n if ( max >= tmp) {\n\n } else {\n max = tmp\n }\n tmp = 0\n }\n }\n println(max)\n}\n\n fun readNext(): String {\n return readLine()!!\n }\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "sample_input": "5\n10 4 8 7 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02923", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 730, "cpu_time_ms": 490, "memory_kb": 57732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s498693608", "group_id": "codeNet:p02924", "input_text": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n println(n * (n - 1) / 2)\n}", "language": "Kotlin", "metadata": {"date": 1567366285, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/Kotlin/s498693608.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s498693608", "user_id": "u122997134"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n var n = readLine()!!.toInt()\n println(n * (n - 1) / 2)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 210, "memory_kb": 31648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s488630617", "group_id": "codeNet:p02925", "input_text": "import java.math.*\n\nval MaxMatch = 499500\n\nval Edges = Array(MaxMatch, { mutableListOf() })\nval RevEdges = Array(MaxMatch, {mutableListOf() })\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n \n val A = Array(N, { readInputLine().split(\" \").map { it.toInt() - 1 }})\n \n val match = Array(N, { IntArray(N - 1, { -1 }) })\n \n val matchMemo = Array(N, { IntArray(N, { -1 })})\n \n var id = 0\n \n for (i in 0 until N) {\n for (j in 0 until N - 1) {\n if (matchMemo[i][A[i][j]] == -1) {\n match[i][j] = id\n matchMemo[i][A[i][j]] = id\n matchMemo[A[i][j]][i] = id\n id++\n } else {\n match[i][j] = matchMemo[i][A[i][j]]\n }\n }\n }\n\n for (m in match) {\n for (i in 1 until N - 1) {\n val matchId = m[i]\n val befId = m[i - 1]\n \n Edges[befId].add(matchId)\n RevEdges[matchId].add(befId)\n }\n }\n\n if (existsCycle()) {\n println(-1)\n return\n }\n\n println(maxPathLength())\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nval NewState = 1\nval ActiveState = 2\nval FinishState = 3\nval nodeStatus = IntArray(MaxMatch, { NewState })\n\nfun existsCycle(): Boolean {\n for (v in 0 until MaxMatch) {\n if (nodeStatus[v] == NewState) {\n if (existsCycleSub(v)) {\n return true\n }\n }\n }\n\n return false\n}\n\nfun existsCycleSub(source: Int): Boolean {\n nodeStatus[source] = ActiveState\n \n for (e in Edges[source]) {\n if (nodeStatus[e] == ActiveState) {\n return true\n } else if (nodeStatus[e] == NewState) {\n if (existsCycleSub(e)) {\n return true\n }\n }\n }\n\n nodeStatus[source] = FinishState\n \n return false\n}\n\nval lengthMemo = IntArray(MaxMatch, { -1 })\n\nfun maxPathLength(): Int {\n var ans = 0\n\n for (v in 0 until MaxMatch) {\n pathLengthSub(v)\n }\n\n return (lengthMemo.max()!! + 1)\n}\n\nfun pathLengthSub(id: Int): Int {\n if (lengthMemo[id] == -1) {\n var length = 0\n \n for (e in RevEdges[id]) {\n length = Math.max(length, pathLengthSub(e) + 1)\n }\n \n lengthMemo[id] = length\n }\n\n return lengthMemo[id]\n}\n", "language": "Kotlin", "metadata": {"date": 1567940695, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Kotlin/s488630617.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s488630617", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.math.*\n\nval MaxMatch = 499500\n\nval Edges = Array(MaxMatch, { mutableListOf() })\nval RevEdges = Array(MaxMatch, {mutableListOf() })\n\nfun main(args: Array) {\n val N = readInputLine().toInt()\n \n val A = Array(N, { readInputLine().split(\" \").map { it.toInt() - 1 }})\n \n val match = Array(N, { IntArray(N - 1, { -1 }) })\n \n val matchMemo = Array(N, { IntArray(N, { -1 })})\n \n var id = 0\n \n for (i in 0 until N) {\n for (j in 0 until N - 1) {\n if (matchMemo[i][A[i][j]] == -1) {\n match[i][j] = id\n matchMemo[i][A[i][j]] = id\n matchMemo[A[i][j]][i] = id\n id++\n } else {\n match[i][j] = matchMemo[i][A[i][j]]\n }\n }\n }\n\n for (m in match) {\n for (i in 1 until N - 1) {\n val matchId = m[i]\n val befId = m[i - 1]\n \n Edges[befId].add(matchId)\n RevEdges[matchId].add(befId)\n }\n }\n\n if (existsCycle()) {\n println(-1)\n return\n }\n\n println(maxPathLength())\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nval NewState = 1\nval ActiveState = 2\nval FinishState = 3\nval nodeStatus = IntArray(MaxMatch, { NewState })\n\nfun existsCycle(): Boolean {\n for (v in 0 until MaxMatch) {\n if (nodeStatus[v] == NewState) {\n if (existsCycleSub(v)) {\n return true\n }\n }\n }\n\n return false\n}\n\nfun existsCycleSub(source: Int): Boolean {\n nodeStatus[source] = ActiveState\n \n for (e in Edges[source]) {\n if (nodeStatus[e] == ActiveState) {\n return true\n } else if (nodeStatus[e] == NewState) {\n if (existsCycleSub(e)) {\n return true\n }\n }\n }\n\n nodeStatus[source] = FinishState\n \n return false\n}\n\nval lengthMemo = IntArray(MaxMatch, { -1 })\n\nfun maxPathLength(): Int {\n var ans = 0\n\n for (v in 0 until MaxMatch) {\n pathLengthSub(v)\n }\n\n return (lengthMemo.max()!! + 1)\n}\n\nfun pathLengthSub(id: Int): Int {\n if (lengthMemo[id] == -1) {\n var length = 0\n \n for (e in RevEdges[id]) {\n length = Math.max(length, pathLengthSub(e) + 1)\n }\n \n lengthMemo[id] = length\n }\n\n return lengthMemo[id]\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2374, "cpu_time_ms": 2111, "memory_kb": 231192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s551954333", "group_id": "codeNet:p02925", "input_text": "import java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val N = scanner.nextInt()\n val A = Array(N, { IntArray(N - 1)})\n\n (0 until N).forEach {i ->\n (0 until N -1).forEach { j ->\n A[i][j] = scanner.nextInt() - 1\n }\n }\n\n val pointers = IntArray(N, { 0 })\n val done = BooleanArray(N, { false })\n\n\n // Simulate day\n var day = 0\n var isAllDone = false\n var players = mutableListOf()\n (0 until N).forEach {\n players.add(it)\n }\n while (!isAllDone) {\n day++\n done.fill(false)\n\n // Set for now\n isAllDone = true\n var updated = false\n\n // O(N)\n val next = mutableListOf()\n players.forEach { index ->\n val pointer = pointers[index]\n if (pointer == N - 1) {\n isAllDone = isAllDone && true\n } else {\n isAllDone = isAllDone && false\n val me = index\n val rival = A[index][pointer]\n val rivalPointer = pointers[rival]\n\n val matched = A[rival][rivalPointer] == me\n if (matched && !done[rival] && !done[index]) {\n pointers[index]++\n pointers[rival]++\n next.add(index)\n next.add(rival)\n done[index] = true\n done[rival] = true\n updated = true\n }\n }\n }\n if (isAllDone) {\n println(day - 1)\n return\n }\n // Fake...\n if (day >= 100000) {\n println(N * (N-1) / 2)\n return\n }\n\n if (!updated) {\n println(-1)\n return\n }\n \n players = next\n }\n println(-1)\n return\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -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 operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) return \"\"\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 fun nextLong(): Long {\n if (!hasNext()) return -1\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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n if (!hasNext()) return -1\n var n: Int = 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()).toInt()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1567436155, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Kotlin/s551954333.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s551954333", "user_id": "u861095163"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val N = scanner.nextInt()\n val A = Array(N, { IntArray(N - 1)})\n\n (0 until N).forEach {i ->\n (0 until N -1).forEach { j ->\n A[i][j] = scanner.nextInt() - 1\n }\n }\n\n val pointers = IntArray(N, { 0 })\n val done = BooleanArray(N, { false })\n\n\n // Simulate day\n var day = 0\n var isAllDone = false\n var players = mutableListOf()\n (0 until N).forEach {\n players.add(it)\n }\n while (!isAllDone) {\n day++\n done.fill(false)\n\n // Set for now\n isAllDone = true\n var updated = false\n\n // O(N)\n val next = mutableListOf()\n players.forEach { index ->\n val pointer = pointers[index]\n if (pointer == N - 1) {\n isAllDone = isAllDone && true\n } else {\n isAllDone = isAllDone && false\n val me = index\n val rival = A[index][pointer]\n val rivalPointer = pointers[rival]\n\n val matched = A[rival][rivalPointer] == me\n if (matched && !done[rival] && !done[index]) {\n pointers[index]++\n pointers[rival]++\n next.add(index)\n next.add(rival)\n done[index] = true\n done[rival] = true\n updated = true\n }\n }\n }\n if (isAllDone) {\n println(day - 1)\n return\n }\n // Fake...\n if (day >= 100000) {\n println(N * (N-1) / 2)\n return\n }\n\n if (!updated) {\n println(-1)\n return\n }\n \n players = next\n }\n println(-1)\n return\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -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 operator fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) return \"\"\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 fun nextLong(): Long {\n if (!hasNext()) return -1\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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n if (!hasNext()) return -1\n var n: Int = 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()).toInt()\n } else return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4509, "cpu_time_ms": 388, "memory_kb": 51592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s857300769", "group_id": "codeNet:p02925", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val A = Array(N, { readInputLine().split(\" \").map { it.toInt() - 1 }})\n val AIndex = IntArray(N)\n\n var ans = 0L\n \n while (true) {\n val used = mutableSetOf()\n var changed = false\n var allClear = true\n \n for (i in 0 until N) {\n if (AIndex[i] >= N - 1 || used.contains(i)) {\n continue\n }\n allClear = false\n \n val other = A[i][AIndex[i]]\n \n if (used.contains(other)) {\n continue\n }\n \n if (A[other][AIndex[other]] == i) {\n used.add(i)\n used.add(other)\n AIndex[i]++\n AIndex[other]++\n changed = true\n }\n }\n \n if (allClear) {\n break\n }\n \n if (!changed) {\n println(-1)\n return\n }\n \n ans++\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1567366455, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Kotlin/s857300769.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s857300769", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val A = Array(N, { readInputLine().split(\" \").map { it.toInt() - 1 }})\n val AIndex = IntArray(N)\n\n var ans = 0L\n \n while (true) {\n val used = mutableSetOf()\n var changed = false\n var allClear = true\n \n for (i in 0 until N) {\n if (AIndex[i] >= N - 1 || used.contains(i)) {\n continue\n }\n allClear = false\n \n val other = A[i][AIndex[i]]\n \n if (used.contains(other)) {\n continue\n }\n \n if (A[other][AIndex[other]] == i) {\n used.add(i)\n used.add(other)\n AIndex[i]++\n AIndex[other]++\n changed = true\n }\n }\n \n if (allClear) {\n break\n }\n \n if (!changed) {\n println(-1)\n return\n }\n \n ans++\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1113, "cpu_time_ms": 2111, "memory_kb": 137236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s197422521", "group_id": "codeNet:p02928", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (n, k) = readListOfInt()\n val a = readListOfLong()\n\n val fallNums = (0 until n).map { (0..1).map { 0L }.toMutableList() }.toMutableList()\n\n for(i in 0 until n) {\n val ai = a[i] \n for(j in 0 until n) {\n val aj = a[j]\n if(ai > aj) {\n if(i < j) { // right side\n fallNums[i][0] = (fallNums[i][0] + 1L)%MOD\n } else { //left side\n fallNums[i][1] = (fallNums[i][1] + 1L)%MOD\n }\n }\n }\n }\n\n val sum_ = { v: Long -> (v * (v+1) / 2) }\n val count = fallNums.fold(0L) { acc, v -> (acc + (v[0] * sum_(k.toLong()))\n + v[1] * sum_((k-1).toLong())) % MOD }\n println(count)\n \n \n pw.flush()\n}\n\nfun > List.upperBound(value: T): Int\n = Collections.binarySearch(this, value, { v1, v2 -> if(v1 > v2) 1 else -1 }).inv()\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n\n// Extensions\nfun List.toBuckets(bucketKeys: List): Map {\n val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()\n this.forEach { t ->\n buckets[t] = buckets[t]!! + 1\n }\n return buckets\n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1566698632, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02928.html", "problem_id": "p02928", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02928/input.txt", "sample_output_relpath": "derived/input_output/data/p02928/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02928/Kotlin/s197422521.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s197422521", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n val (n, k) = readListOfInt()\n val a = readListOfLong()\n\n val fallNums = (0 until n).map { (0..1).map { 0L }.toMutableList() }.toMutableList()\n\n for(i in 0 until n) {\n val ai = a[i] \n for(j in 0 until n) {\n val aj = a[j]\n if(ai > aj) {\n if(i < j) { // right side\n fallNums[i][0] = (fallNums[i][0] + 1L)%MOD\n } else { //left side\n fallNums[i][1] = (fallNums[i][1] + 1L)%MOD\n }\n }\n }\n }\n\n val sum_ = { v: Long -> (v * (v+1) / 2) }\n val count = fallNums.fold(0L) { acc, v -> (acc + (v[0] * sum_(k.toLong()))\n + v[1] * sum_((k-1).toLong())) % MOD }\n println(count)\n \n \n pw.flush()\n}\n\nfun > List.upperBound(value: T): Int\n = Collections.binarySearch(this, value, { v1, v2 -> if(v1 > v2) 1 else -1 }).inv()\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n\n// Extensions\nfun List.toBuckets(bucketKeys: List): Map {\n val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()\n this.forEach { t ->\n buckets[t] = buckets[t]!! + 1\n }\n return buckets\n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun permutations(src: List): List> {\n if(src.size == 1) return listOf(src)\n val perms = mutableListOf>()\n val insertElement = src[0]\n permutations(src.drop(1)).forEach { perm ->\n for(i in 0..perm.size) {\n val newPerm = perm.toMutableList()\n newPerm.add(i, insertElement)\n perms.add(newPerm.toList())\n }\n }\n return perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n for(i in 0 until v.size) {\n v[i][0] = 1L\n v[i][i] = 1L\n }\n for(i in 0 until v.size) {\n for(j in 1 until i) {\n v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n }\n }\n return v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n if(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n a / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\nfun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n fun isEmpty() = st.isEmpty()\n fun top(): T = st.last()\n fun push(e: T) { st.add(e) }\n fun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n fun isEmpty() = que.isEmpty()\n fun top(): T = que.first()\n fun push(e: T) { que.add(e) }\n fun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "sample_input": "2 2\n2 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02928", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3828, "cpu_time_ms": 365, "memory_kb": 45556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s444919512", "group_id": "codeNet:p02934", "input_text": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n\n 1.0/a.map { 1.0/it }.sum()\n})", "language": "Kotlin", "metadata": {"date": 1588618878, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02934/input.txt", "sample_output_relpath": "derived/input_output/data/p02934/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02934/Kotlin/s444919512.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444919512", "user_id": "u563556491"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n\n 1.0/a.map { 1.0/it }.sum()\n})", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 168, "cpu_time_ms": 237, "memory_kb": 38028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s941377738", "group_id": "codeNet:p02934", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0.0\n for (i in 0 until n) {\n val b = a[i]\n ans += 1.0 / b\n }\n println(1.0 / ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1575336521, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02934/input.txt", "sample_output_relpath": "derived/input_output/data/p02934/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02934/Kotlin/s941377738.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941377738", "user_id": "u396701320"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var ans = 0.0\n for (i in 0 until n) {\n val b = a[i]\n ans += 1.0 / b\n }\n println(1.0 / ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 240, "cpu_time_ms": 235, "memory_kb": 35976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s856388127", "group_id": "codeNet:p02935", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int, v: IntArray){\n v.sorted().map{ it.toDouble() }.reduce{ a, b -> (a+b) / 2 }.let{ println(it) }\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val v = IntArray(N)\n for (i in 0 until N) {\n v[i] = sc.next().toInt()\n }\n solve(N, v)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1566226365, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02935.html", "problem_id": "p02935", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02935/input.txt", "sample_output_relpath": "derived/input_output/data/p02935/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02935/Kotlin/s856388127.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856388127", "user_id": "u329232967"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int, v: IntArray){\n v.sorted().map{ it.toDouble() }.reduce{ a, b -> (a+b) / 2 }.let{ println(it) }\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val v = IntArray(N)\n for (i in 0 until N) {\n v[i] = sc.next().toInt()\n }\n solve(N, v)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 841, "cpu_time_ms": 205, "memory_kb": 34088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s759567759", "group_id": "codeNet:p02935", "input_text": "import java.util.*\nfun main(arg: Array) {\n val N = nextInt()\n val V = listOfDouble().sorted()\n var ans = V[0]\n for (n in 1 until N) ans = (ans + V[n]) / 2\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfDouble() = listOfString().map { java.lang.Double.parseDouble(it) }", "language": "Kotlin", "metadata": {"date": 1566185726, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02935.html", "problem_id": "p02935", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02935/input.txt", "sample_output_relpath": "derived/input_output/data/p02935/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02935/Kotlin/s759567759.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s759567759", "user_id": "u043150661"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "import java.util.*\nfun main(arg: Array) {\n val N = nextInt()\n val V = listOfDouble().sorted()\n var ans = V[0]\n for (n in 1 until N) ans = (ans + V[n]) / 2\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfDouble() = listOfString().map { java.lang.Double.parseDouble(it) }", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 244, "memory_kb": 37868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s738308798", "group_id": "codeNet:p02937", "input_text": "import java.io.BufferedReader\nimport java.util.*\n\nfun main() = abc138e()\n\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc138e() = SimpleFastIOWithToken_abc138e().exec {\n val s = readString()\n val t = readString()\n fun Char.toIndex() = this - 'a'\n\n val appearIndices = Array(26) { mutableListOf() }\n\n for ((index, sc) in s.repeat(2).withIndex()) {\n appearIndices[sc.toIndex()].add(index)\n }\n\n var currentIndex = s.lastIndex\n var answer = 0\n\n for (tc in t) {\n val indices = appearIndices[tc.toIndex()]\n val lb = indices.upperBound(currentIndex)\n val nextIndex = indices.getOrNull(lb) ?: return@exec println(-1)\n answer += nextIndex - currentIndex\n currentIndex = nextIndex % s.length\n }\n\n println(answer)\n}\n\nprivate fun List.upperBound(key: Int): Int {\n var ng = -1\n var ok = size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] > key) ok = mid else ng = mid\n }\n return ok\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"HasPlatformType\", \"MemberVisibilityCanBePrivate\", \"ClassName\")\nprivate class SimpleFastIOWithToken_abc138e(private val separator: String = System.lineSeparator()) {\n private val br: BufferedReader = System.`in`.bufferedReader()\n private var st: StringTokenizer = StringTokenizer(\"\")\n private val sb: StringBuilder = StringBuilder()\n private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }\n\n fun readString(): String = run { prepareNext() }.run { st.nextToken() }\n fun readStringList(size: Int): List = List(size) { readString() }\n fun readInt(): Int = Integer.valueOf(readString())\n fun readIntList(size: Int): List = List(size) { readInt() }\n fun readLong(): Long = java.lang.Long.valueOf(readString())\n fun readLongList(size: Int): List = List(size) { readLong() }\n inline fun readArray(size: Int, init: () -> T) = Array(size) { init() }\n inline fun readList(size: Int, init: () -> T) = List(size) { init() }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = print(any.toString() + separator)\n\n fun exec(action: SimpleFastIOWithToken_abc138e.() -> Unit) = run {\n Thread(null, { action() }, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n }.run { kotlin.io.print(sb) }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "language": "Kotlin", "metadata": {"date": 1595585986, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/Kotlin/s738308798.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s738308798", "user_id": "u139478771"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.util.*\n\nfun main() = abc138e()\n\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc138e() = SimpleFastIOWithToken_abc138e().exec {\n val s = readString()\n val t = readString()\n fun Char.toIndex() = this - 'a'\n\n val appearIndices = Array(26) { mutableListOf() }\n\n for ((index, sc) in s.repeat(2).withIndex()) {\n appearIndices[sc.toIndex()].add(index)\n }\n\n var currentIndex = s.lastIndex\n var answer = 0\n\n for (tc in t) {\n val indices = appearIndices[tc.toIndex()]\n val lb = indices.upperBound(currentIndex)\n val nextIndex = indices.getOrNull(lb) ?: return@exec println(-1)\n answer += nextIndex - currentIndex\n currentIndex = nextIndex % s.length\n }\n\n println(answer)\n}\n\nprivate fun List.upperBound(key: Int): Int {\n var ng = -1\n var ok = size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] > key) ok = mid else ng = mid\n }\n return ok\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"HasPlatformType\", \"MemberVisibilityCanBePrivate\", \"ClassName\")\nprivate class SimpleFastIOWithToken_abc138e(private val separator: String = System.lineSeparator()) {\n private val br: BufferedReader = System.`in`.bufferedReader()\n private var st: StringTokenizer = StringTokenizer(\"\")\n private val sb: StringBuilder = StringBuilder()\n private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }\n\n fun readString(): String = run { prepareNext() }.run { st.nextToken() }\n fun readStringList(size: Int): List = List(size) { readString() }\n fun readInt(): Int = Integer.valueOf(readString())\n fun readIntList(size: Int): List = List(size) { readInt() }\n fun readLong(): Long = java.lang.Long.valueOf(readString())\n fun readLongList(size: Int): List = List(size) { readLong() }\n inline fun readArray(size: Int, init: () -> T) = Array(size) { init() }\n inline fun readList(size: Int, init: () -> T) = List(size) { init() }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = print(any.toString() + separator)\n\n fun exec(action: SimpleFastIOWithToken_abc138e.() -> Unit) = run {\n Thread(null, { action() }, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n }.run { kotlin.io.print(sb) }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2564, "cpu_time_ms": 253, "memory_kb": 46696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s037883206", "group_id": "codeNet:p02937", "input_text": "import java.io.BufferedReader\nimport java.util.*\n\nfun main() = abc138e()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc138e() = SimpleFastIOWithToken_abc138e().exec {\n val s = readString()\n val t = readString()\n fun Char.toIndex() = this - 'a'\n\n val nextAppearDist = Array(26) { IntArray(s.length) }\n val repeatedS = s.repeat(2)\n\n for (tChar in t.toSet()) {\n var distToNext = 0\n for (i in repeatedS.indices.reversed()) {\n if (repeatedS[i] == tChar) distToNext = 0 else distToNext++\n if (i in s.indices) nextAppearDist[tChar.toIndex()][i] = distToNext\n }\n if (distToNext == repeatedS.length) return@exec println(-1)\n }\n\n var answer = 0\n var beforeIndex = -1\n\n for (tChar in t) {\n val nextDist = nextAppearDist[tChar.toIndex()][answer % s.length]\n val nextIndex = (answer + nextDist) % s.length\n val moveDist = if (beforeIndex == nextIndex) s.length else nextDist\n answer += moveDist\n beforeIndex = nextIndex\n }\n\n println(++answer)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"HasPlatformType\", \"MemberVisibilityCanBePrivate\", \"ClassName\")\nprivate class SimpleFastIOWithToken_abc138e(private val separator: String = System.lineSeparator()) {\n private val br: BufferedReader = System.`in`.bufferedReader()\n private var st: StringTokenizer = StringTokenizer(\"\")\n private val sb: StringBuilder = StringBuilder()\n private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }\n\n fun readString(): String = run { prepareNext() }.run { st.nextToken() }\n fun readStringList(size: Int): List = List(size) { readString() }\n fun readInt(): Int = Integer.valueOf(readString())\n fun readIntList(size: Int): List = List(size) { readInt() }\n fun readLong(): Long = java.lang.Long.valueOf(readString())\n fun readLongList(size: Int): List = List(size) { readLong() }\n inline fun readArray(size: Int, init: () -> T) = Array(size) { init() }\n inline fun readList(size: Int, init: () -> T) = List(size) { init() }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = print(any.toString() + separator)\n\n fun exec(action: SimpleFastIOWithToken_abc138e.() -> Unit) = run {\n Thread(null, { action() }, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n }.run { kotlin.io.print(sb) }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "language": "Kotlin", "metadata": {"date": 1595582239, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/Kotlin/s037883206.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s037883206", "user_id": "u139478771"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.util.*\n\nfun main() = abc138e()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc138e() = SimpleFastIOWithToken_abc138e().exec {\n val s = readString()\n val t = readString()\n fun Char.toIndex() = this - 'a'\n\n val nextAppearDist = Array(26) { IntArray(s.length) }\n val repeatedS = s.repeat(2)\n\n for (tChar in t.toSet()) {\n var distToNext = 0\n for (i in repeatedS.indices.reversed()) {\n if (repeatedS[i] == tChar) distToNext = 0 else distToNext++\n if (i in s.indices) nextAppearDist[tChar.toIndex()][i] = distToNext\n }\n if (distToNext == repeatedS.length) return@exec println(-1)\n }\n\n var answer = 0\n var beforeIndex = -1\n\n for (tChar in t) {\n val nextDist = nextAppearDist[tChar.toIndex()][answer % s.length]\n val nextIndex = (answer + nextDist) % s.length\n val moveDist = if (beforeIndex == nextIndex) s.length else nextDist\n answer += moveDist\n beforeIndex = nextIndex\n }\n\n println(++answer)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"HasPlatformType\", \"MemberVisibilityCanBePrivate\", \"ClassName\")\nprivate class SimpleFastIOWithToken_abc138e(private val separator: String = System.lineSeparator()) {\n private val br: BufferedReader = System.`in`.bufferedReader()\n private var st: StringTokenizer = StringTokenizer(\"\")\n private val sb: StringBuilder = StringBuilder()\n private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }\n\n fun readString(): String = run { prepareNext() }.run { st.nextToken() }\n fun readStringList(size: Int): List = List(size) { readString() }\n fun readInt(): Int = Integer.valueOf(readString())\n fun readIntList(size: Int): List = List(size) { readInt() }\n fun readLong(): Long = java.lang.Long.valueOf(readString())\n fun readLongList(size: Int): List = List(size) { readLong() }\n inline fun readArray(size: Int, init: () -> T) = Array(size) { init() }\n inline fun readList(size: Int, init: () -> T) = List(size) { init() }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = print(any.toString() + separator)\n\n fun exec(action: SimpleFastIOWithToken_abc138e.() -> Unit) = run {\n Thread(null, { action() }, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n }.run { kotlin.io.print(sb) }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2615, "cpu_time_ms": 269, "memory_kb": 51940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s543575366", "group_id": "codeNet:p02939", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(problem037a(s))\n}\n\nfun problem037a(s: String): Int {\n var count = 1\n var prev = s[0].toString()\n var current = \"\"\n for (i in 1 until s.length) {\n current += s[i]\n if (prev != current) {\n prev = current\n current = \"\"\n count++\n continue\n }\n }\n return count\n}", "language": "Kotlin", "metadata": {"date": 1590105604, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02939.html", "problem_id": "p02939", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02939/input.txt", "sample_output_relpath": "derived/input_output/data/p02939/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02939/Kotlin/s543575366.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s543575366", "user_id": "u073232808"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(problem037a(s))\n}\n\nfun problem037a(s: String): Int {\n var count = 1\n var prev = s[0].toString()\n var current = \"\"\n for (i in 1 until s.length) {\n current += s[i]\n if (prev != current) {\n prev = current\n current = \"\"\n count++\n continue\n }\n }\n return count\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:\n\nThere exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \\neq S_{i+1} (1 \\leq i \\leq K-1).\n\nHere S_1S_2...S_K represents the concatenation of S_1,S_2,...,S_K in this order.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum positive integer K that satisfies the condition.\n\nSample Input 1\n\naabbaa\n\nSample Output 1\n\n4\n\nWe can, for example, divide S into four strings aa, b, ba, and a.\n\nSample Input 2\n\naaaccacabaababc\n\nSample Output 2\n\n12", "sample_input": "aabbaa\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02939", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:\n\nThere exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \\neq S_{i+1} (1 \\leq i \\leq K-1).\n\nHere S_1S_2...S_K represents the concatenation of S_1,S_2,...,S_K in this order.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum positive integer K that satisfies the condition.\n\nSample Input 1\n\naabbaa\n\nSample Output 1\n\n4\n\nWe can, for example, divide S into four strings aa, b, ba, and a.\n\nSample Input 2\n\naaaccacabaababc\n\nSample Output 2\n\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 459, "cpu_time_ms": 320, "memory_kb": 39840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s406137624", "group_id": "codeNet:p02939", "input_text": "fun main(args: Array) {\n agc037a()\n}\n\nfun agc037a() {\n val s = readLine()!!\n\n // dp[i文字目まで使用][次の文字を使う?(0/1)] = 答えの最大値\n val dp = Array(s.length) { LongArray(2) { 0 } }\n dp[0][0] = 1\n dp[0][1] = 1\n\n for (i in 1..s.lastIndex) {\n dp[i][0] = 1 + if (s[i] == s[i - 1]) dp[i - 1][1] else Math.max(dp[i - 1][0], dp[i - 1][1])\n dp[i][1] = if (i + 1 <= s.lastIndex && i - 2 >= 0 &&\n s[i].toString() + s[i + 1].toString() == s[i - 2].toString() + s[i - 1].toString()\n ) {\n 1 + dp[i - 1][0]\n } else {\n Math.max(dp[i - 1][0], dp[i - 1][1])\n }\n }\n\n val answer = dp.last().max()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1576481078, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02939.html", "problem_id": "p02939", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02939/input.txt", "sample_output_relpath": "derived/input_output/data/p02939/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02939/Kotlin/s406137624.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s406137624", "user_id": "u139478771"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n agc037a()\n}\n\nfun agc037a() {\n val s = readLine()!!\n\n // dp[i文字目まで使用][次の文字を使う?(0/1)] = 答えの最大値\n val dp = Array(s.length) { LongArray(2) { 0 } }\n dp[0][0] = 1\n dp[0][1] = 1\n\n for (i in 1..s.lastIndex) {\n dp[i][0] = 1 + if (s[i] == s[i - 1]) dp[i - 1][1] else Math.max(dp[i - 1][0], dp[i - 1][1])\n dp[i][1] = if (i + 1 <= s.lastIndex && i - 2 >= 0 &&\n s[i].toString() + s[i + 1].toString() == s[i - 2].toString() + s[i - 1].toString()\n ) {\n 1 + dp[i - 1][0]\n } else {\n Math.max(dp[i - 1][0], dp[i - 1][1])\n }\n }\n\n val answer = dp.last().max()\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:\n\nThere exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \\neq S_{i+1} (1 \\leq i \\leq K-1).\n\nHere S_1S_2...S_K represents the concatenation of S_1,S_2,...,S_K in this order.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum positive integer K that satisfies the condition.\n\nSample Input 1\n\naabbaa\n\nSample Output 1\n\n4\n\nWe can, for example, divide S into four strings aa, b, ba, and a.\n\nSample Input 2\n\naaaccacabaababc\n\nSample Output 2\n\n12", "sample_input": "aabbaa\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02939", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:\n\nThere exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \\neq S_{i+1} (1 \\leq i \\leq K-1).\n\nHere S_1S_2...S_K represents the concatenation of S_1,S_2,...,S_K in this order.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum positive integer K that satisfies the condition.\n\nSample Input 1\n\naabbaa\n\nSample Output 1\n\n4\n\nWe can, for example, divide S into four strings aa, b, ba, and a.\n\nSample Input 2\n\naaaccacabaababc\n\nSample Output 2\n\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 732, "cpu_time_ms": 364, "memory_kb": 62912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s016620515", "group_id": "codeNet:p02945", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (A, B) = readLine()!!.split(\" \").map {it.toInt()}\n\n println(Collections.max(listOf(A + B, A - B, A * B)))\n}\n", "language": "Kotlin", "metadata": {"date": 1572833307, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02945/input.txt", "sample_output_relpath": "derived/input_output/data/p02945/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02945/Kotlin/s016620515.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s016620515", "user_id": "u183530284"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (A, B) = readLine()!!.split(\" \").map {it.toInt()}\n\n println(Collections.max(listOf(A + B, A - B, A * B)))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 171, "cpu_time_ms": 234, "memory_kb": 37932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s232256242", "group_id": "codeNet:p02945", "input_text": "fun main(args: Array) {\n val line = readLine()!!\n val A = line.split(\" \")[0].toInt()\n val B = line.split(\" \")[1].toInt()\n\n val tasu = A + B\n val hiku = A - B\n val kakeru = A * B\n\n if (tasu >= hiku) {\n if (tasu >= kakeru) {\n println(tasu)\n } else {\n println(kakeru)\n }\n } else {\n if (hiku >= kakeru) {\n println(hiku)\n } else {\n println(kakeru)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1565485579, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02945/input.txt", "sample_output_relpath": "derived/input_output/data/p02945/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02945/Kotlin/s232256242.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232256242", "user_id": "u388719350"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "fun main(args: Array) {\n val line = readLine()!!\n val A = line.split(\" \")[0].toInt()\n val B = line.split(\" \")[1].toInt()\n\n val tasu = A + B\n val hiku = A - B\n val kakeru = A * B\n\n if (tasu >= hiku) {\n if (tasu >= kakeru) {\n println(tasu)\n } else {\n println(kakeru)\n }\n } else {\n if (hiku >= kakeru) {\n println(hiku)\n } else {\n println(kakeru)\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 471, "cpu_time_ms": 266, "memory_kb": 37912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s108532447", "group_id": "codeNet:p02945", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (a, b) = listOfInt()\n println(Math.max(Math.max(a + b, a - b), a * b))\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1565485332, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02945/input.txt", "sample_output_relpath": "derived/input_output/data/p02945/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02945/Kotlin/s108532447.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s108532447", "user_id": "u262403099"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (a, b) = listOfInt()\n println(Math.max(Math.max(a + b, a - b), a * b))\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 235, "memory_kb": 37864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s872319267", "group_id": "codeNet:p02946", "input_text": "fun main (args : Array) {\n\tval (k, x) = readLine()!!.split(\" \")\n\tval K : Int = k.toInt()\n\tval X : Int = x.toInt()\n\tvar result : Int = X - (K - 1)\n\tvar str : String = \"\"\n\tstr += result\n\tstr += \" \"\n\tfor (i in result..(X + (K - 1)) - 1) {\n\t\tresult++\n\t\tstr += result\n\t\tstr += \" \"\n\t}\n\tprintln(\"${str}\")\n}", "language": "Kotlin", "metadata": {"date": 1568473383, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02946/input.txt", "sample_output_relpath": "derived/input_output/data/p02946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02946/Kotlin/s872319267.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872319267", "user_id": "u651257341"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "fun main (args : Array) {\n\tval (k, x) = readLine()!!.split(\" \")\n\tval K : Int = k.toInt()\n\tval X : Int = x.toInt()\n\tvar result : Int = X - (K - 1)\n\tvar str : String = \"\"\n\tstr += result\n\tstr += \" \"\n\tfor (i in result..(X + (K - 1)) - 1) {\n\t\tresult++\n\t\tstr += result\n\t\tstr += \" \"\n\t}\n\tprintln(\"${str}\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "sample_input": "3 7\n"}, "reference_outputs": ["5 6 7 8 9\n"], "source_document_id": "p02946", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 307, "cpu_time_ms": 243, "memory_kb": 38640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s193514714", "group_id": "codeNet:p02946", "input_text": "import java.util.*\n\nfun main(args : Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextLong()\n val x = sc.nextLong()\n println(problem137b(k, x))\n}\n\nfun problem137b(k: Long, x: Long): String {\n return (x - k + 1 until x + k).joinToString( \" \")\n}", "language": "Kotlin", "metadata": {"date": 1565485966, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02946/input.txt", "sample_output_relpath": "derived/input_output/data/p02946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02946/Kotlin/s193514714.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s193514714", "user_id": "u073232808"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextLong()\n val x = sc.nextLong()\n println(problem137b(k, x))\n}\n\nfun problem137b(k: Long, x: Long): String {\n return (x - k + 1 until x + k).joinToString( \" \")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "sample_input": "3 7\n"}, "reference_outputs": ["5 6 7 8 9\n"], "source_document_id": "p02946", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 272, "cpu_time_ms": 207, "memory_kb": 31524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s593852702", "group_id": "codeNet:p02946", "input_text": "fun main(args: Array) {\n val (k, x) = readLine()!!.split(\" \").map { it.toInt() }\n\n val ans = mutableListOf()\n for ( i in 1..k-1) {\n ans.add(x-i)\n }\n ans.reverse()\n\n for ( i in 0..k-1) {\n ans.add(x+i)\n }\n\n println(ans.joinToString(\" \"))\n}", "language": "Kotlin", "metadata": {"date": 1565485745, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02946/input.txt", "sample_output_relpath": "derived/input_output/data/p02946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02946/Kotlin/s593852702.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593852702", "user_id": "u889750959"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "fun main(args: Array) {\n val (k, x) = readLine()!!.split(\" \").map { it.toInt() }\n\n val ans = mutableListOf()\n for ( i in 1..k-1) {\n ans.add(x-i)\n }\n ans.reverse()\n\n for ( i in 0..k-1) {\n ans.add(x+i)\n }\n\n println(ans.joinToString(\" \"))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "sample_input": "3 7\n"}, "reference_outputs": ["5 6 7 8 9\n"], "source_document_id": "p02946", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 238, "memory_kb": 36144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s777167887", "group_id": "codeNet:p02947", "input_text": "fun main(args: Array) {\n // Your code here!\n val n = readLine()!!.toInt()\n var list = (1..n).map {readLine()!!.toCharArray().sorted()}\n \n println(list.groupBy { it }.map { it.value.size.toLong() }.map { (it - 1) * it / 2 }.fold(0L, Long::plus))\n}", "language": "Kotlin", "metadata": {"date": 1587662372, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02947/input.txt", "sample_output_relpath": "derived/input_output/data/p02947/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02947/Kotlin/s777167887.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s777167887", "user_id": "u808976884"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n // Your code here!\n val n = readLine()!!.toInt()\n var list = (1..n).map {readLine()!!.toCharArray().sorted()}\n \n println(list.groupBy { it }.map { it.value.size.toLong() }.map { (it - 1) * it / 2 }.fold(0L, Long::plus))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 868, "memory_kb": 77212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s006580012", "group_id": "codeNet:p02947", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val strs = Array(N) { readLine()!!.toCharArray().sorted().joinToString(\"\") }\n val map = mutableMapOf()\n for (str in strs) {\n if (map.contains(str)) {\n val cnt = map[str]!!\n map[str] = cnt + cnt + 1L\n } else {\n map[str] = 0L\n }\n }\n map.values.sum().let(::println)\n\n}\n\n", "language": "Kotlin", "metadata": {"date": 1567481010, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02947/input.txt", "sample_output_relpath": "derived/input_output/data/p02947/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02947/Kotlin/s006580012.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s006580012", "user_id": "u085288971"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val strs = Array(N) { readLine()!!.toCharArray().sorted().joinToString(\"\") }\n val map = mutableMapOf()\n for (str in strs) {\n if (map.contains(str)) {\n val cnt = map[str]!!\n map[str] = cnt + cnt + 1L\n } else {\n map[str] = 0L\n }\n }\n map.values.sum().let(::println)\n\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 416, "cpu_time_ms": 713, "memory_kb": 79096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s343777779", "group_id": "codeNet:p02947", "input_text": "fun main(arg: Array) {\n val N = nextInt()\n val S = Array(N) {\"\"}\n repeat(N) {\n S[it] = next().toCharArray().sorted().joinToString(separator = \"\")\n }\n //S.sort()\n val A = S.sorted().groupBy{ it }.map{ Pair(it.key, it.value.size) }\n var ans = 0L\n A.forEach { ans += ((it.second * (it.second - 1)) / 2) }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\n", "language": "Kotlin", "metadata": {"date": 1565574500, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02947/input.txt", "sample_output_relpath": "derived/input_output/data/p02947/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02947/Kotlin/s343777779.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s343777779", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(arg: Array) {\n val N = nextInt()\n val S = Array(N) {\"\"}\n repeat(N) {\n S[it] = next().toCharArray().sorted().joinToString(separator = \"\")\n }\n //S.sort()\n val A = S.sorted().groupBy{ it }.map{ Pair(it.key, it.value.size) }\n var ans = 0L\n A.forEach { ans += ((it.second * (it.second - 1)) / 2) }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 433, "cpu_time_ms": 1270, "memory_kb": 80888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s942971359", "group_id": "codeNet:p02947", "input_text": "import java.util.HashMap\n\nfun main(args: Array) {\n val n = readNext()\n val k = Integer.parseInt(n)\n var hashMap = HashMap()\n var result = 0\n for (i in 1..k) {\n val input = readNext().split(\"\")\n var str = \"\"\n input.sorted().map {\n str += it\n }\n hashMap.contains(str).let {\n if (it) {\n hashMap.put(str, hashMap.get(str)!!.plus(1))\n }else {\n hashMap.put(str, 0)\n }\n }\n }\n hashMap.forEach {\n result += it.value\n }\n println(result)\n\n\n }\n\n\n fun readNext(): String {\n return readLine()!!\n }\n", "language": "Kotlin", "metadata": {"date": 1565538165, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02947/input.txt", "sample_output_relpath": "derived/input_output/data/p02947/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02947/Kotlin/s942971359.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s942971359", "user_id": "u376174428"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.HashMap\n\nfun main(args: Array) {\n val n = readNext()\n val k = Integer.parseInt(n)\n var hashMap = HashMap()\n var result = 0\n for (i in 1..k) {\n val input = readNext().split(\"\")\n var str = \"\"\n input.sorted().map {\n str += it\n }\n hashMap.contains(str).let {\n if (it) {\n hashMap.put(str, hashMap.get(str)!!.plus(1))\n }else {\n hashMap.put(str, 0)\n }\n }\n }\n hashMap.forEach {\n result += it.value\n }\n println(result)\n\n\n }\n\n\n fun readNext(): String {\n return readLine()!!\n }\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 759, "cpu_time_ms": 892, "memory_kb": 116692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s749319238", "group_id": "codeNet:p02950", "input_text": "import java.util.*\n\nobject Mod {\n var num: Long = 1000000007\n val inverse: HashMap = hashMapOf()\n val factorial: HashMap = hashMapOf()\n}\n\nfun Long.pls(other: Long): Long {\n return (this + other) % Mod.num\n}\n\nfun Long.mns(other: Long): Long {\n return (this - other) % Mod.num\n}\n\nfun Long.mult(other: Long): Long {\n return ((this % Mod.num) * (other % Mod.num)) % Mod.num\n}\n\nfun Long.divi(other: Long): Long {\n return ((this % Mod.num) * other.inverse()) % Mod.num\n}\n\nfun Long.power(num: Int): Long {\n var res: Long = 1\n var a = this\n var n = num\n while (n > 0) {\n if (n % 2 == 1) {\n res = res.mult(a)\n }\n a = a.mult(a)\n n = n shr 1\n }\n return res\n}\n\nfun Long.inverse(): Long {\n val ans = Mod.inverse[this]\n return if (ans != null) {\n ans\n } else {\n val ans2 = this.power((Mod.num - 2).toInt())\n Mod.inverse[this] = ans2\n ans2\n }\n}\n\nfun Long.factorial(): Long {\n if (this == 1.toLong()) return 1\n val ans = Mod.factorial[this]\n return if (ans != null) {\n ans\n } else {\n var ans2: Long = 1\n for (i in 1..this) {\n ans2 = ans2.mult(i)\n }\n Mod.factorial[this] = ans2\n ans2\n }\n}\n\nfun Long.combi(other: Long): Long {\n if (this < other) return 0\n if (other == this || other == 0.toLong()) return 1\n return this.factorial()\n .mult(other.factorial().inverse())\n .mult((this - other).factorial().inverse())\n}\n\nfun main(args: Array) {\n val p = readLine()!!.toInt()\n Mod.num = p.toLong()\n val array = readLine()!!.split(' ').map(String::toInt)\n val p_1C = hashMapOf()\n for (k in 0..(p - 1).toLong()) {\n p_1C[k] = (p - 1).toLong().combi(k)\n }\n val ans = Array(p) { 0 }\n for (i in 0 until p) {\n if (array[i] == 0) continue\n ans[0] = ans[0].pls(1)\n for (k in 0..(p - 1)) {\n ans[k] = ans[k].mns(\n p_1C[k.toLong()]!!.mult((-i.toLong()).power(p - 1 - k))\n )\n }\n }\n println(ans.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1565584843, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02950.html", "problem_id": "p02950", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02950/input.txt", "sample_output_relpath": "derived/input_output/data/p02950/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02950/Kotlin/s749319238.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s749319238", "user_id": "u572745161"}, "prompt_components": {"gold_output": "1 1\n", "input_to_evaluate": "import java.util.*\n\nobject Mod {\n var num: Long = 1000000007\n val inverse: HashMap = hashMapOf()\n val factorial: HashMap = hashMapOf()\n}\n\nfun Long.pls(other: Long): Long {\n return (this + other) % Mod.num\n}\n\nfun Long.mns(other: Long): Long {\n return (this - other) % Mod.num\n}\n\nfun Long.mult(other: Long): Long {\n return ((this % Mod.num) * (other % Mod.num)) % Mod.num\n}\n\nfun Long.divi(other: Long): Long {\n return ((this % Mod.num) * other.inverse()) % Mod.num\n}\n\nfun Long.power(num: Int): Long {\n var res: Long = 1\n var a = this\n var n = num\n while (n > 0) {\n if (n % 2 == 1) {\n res = res.mult(a)\n }\n a = a.mult(a)\n n = n shr 1\n }\n return res\n}\n\nfun Long.inverse(): Long {\n val ans = Mod.inverse[this]\n return if (ans != null) {\n ans\n } else {\n val ans2 = this.power((Mod.num - 2).toInt())\n Mod.inverse[this] = ans2\n ans2\n }\n}\n\nfun Long.factorial(): Long {\n if (this == 1.toLong()) return 1\n val ans = Mod.factorial[this]\n return if (ans != null) {\n ans\n } else {\n var ans2: Long = 1\n for (i in 1..this) {\n ans2 = ans2.mult(i)\n }\n Mod.factorial[this] = ans2\n ans2\n }\n}\n\nfun Long.combi(other: Long): Long {\n if (this < other) return 0\n if (other == this || other == 0.toLong()) return 1\n return this.factorial()\n .mult(other.factorial().inverse())\n .mult((this - other).factorial().inverse())\n}\n\nfun main(args: Array) {\n val p = readLine()!!.toInt()\n Mod.num = p.toLong()\n val array = readLine()!!.split(' ').map(String::toInt)\n val p_1C = hashMapOf()\n for (k in 0..(p - 1).toLong()) {\n p_1C[k] = (p - 1).toLong().combi(k)\n }\n val ans = Array(p) { 0 }\n for (i in 0 until p) {\n if (array[i] == 0) continue\n ans[0] = ans[0].pls(1)\n for (k in 0..(p - 1)) {\n ans[k] = ans[k].mns(\n p_1C[k.toLong()]!!.mult((-i.toLong()).power(p - 1 - k))\n )\n }\n }\n println(ans.joinToString(\" \"))\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are a prime number p and a sequence of p integers a_0, \\ldots, a_{p-1} consisting of zeros and ones.\n\nFind a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \\ldots + b_0, satisfying the following conditions:\n\nFor each i (0 \\leq i \\leq p-1), b_i is an integer such that 0 \\leq b_i \\leq p-1.\n\nFor each i (0 \\leq i \\leq p-1), f(i) \\equiv a_i \\pmod p.\n\nConstraints\n\n2 \\leq p \\leq 2999\n\np is a prime number.\n\n0 \\leq a_i \\leq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\np\na_0 a_1 \\ldots a_{p-1}\n\nOutput\n\nPrint b_0, b_1, \\ldots, b_{p-1} of a polynomial f(x) satisfying the conditions, in this order, with spaces in between.\n\nIt can be proved that a solution always exists. If multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n2\n1 0\n\nSample Output 1\n\n1 1\n\nf(x) = x + 1 satisfies the conditions, as follows:\n\nf(0) = 0 + 1 = 1 \\equiv 1 \\pmod 2\n\nf(1) = 1 + 1 = 2 \\equiv 0 \\pmod 2\n\nSample Input 2\n\n3\n0 0 0\n\nSample Output 2\n\n0 0 0\n\nf(x) = 0 is also valid.\n\nSample Input 3\n\n5\n0 1 0 1 0\n\nSample Output 3\n\n0 2 0 1 3", "sample_input": "2\n1 0\n"}, "reference_outputs": ["1 1\n"], "source_document_id": "p02950", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are a prime number p and a sequence of p integers a_0, \\ldots, a_{p-1} consisting of zeros and ones.\n\nFind a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \\ldots + b_0, satisfying the following conditions:\n\nFor each i (0 \\leq i \\leq p-1), b_i is an integer such that 0 \\leq b_i \\leq p-1.\n\nFor each i (0 \\leq i \\leq p-1), f(i) \\equiv a_i \\pmod p.\n\nConstraints\n\n2 \\leq p \\leq 2999\n\np is a prime number.\n\n0 \\leq a_i \\leq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\np\na_0 a_1 \\ldots a_{p-1}\n\nOutput\n\nPrint b_0, b_1, \\ldots, b_{p-1} of a polynomial f(x) satisfying the conditions, in this order, with spaces in between.\n\nIt can be proved that a solution always exists. If multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n2\n1 0\n\nSample Output 1\n\n1 1\n\nf(x) = x + 1 satisfies the conditions, as follows:\n\nf(0) = 0 + 1 = 1 \\equiv 1 \\pmod 2\n\nf(1) = 1 + 1 = 2 \\equiv 0 \\pmod 2\n\nSample Input 2\n\n3\n0 0 0\n\nSample Output 2\n\n0 0 0\n\nf(x) = 0 is also valid.\n\nSample Input 3\n\n5\n0 1 0 1 0\n\nSample Output 3\n\n0 2 0 1 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2139, "cpu_time_ms": 2111, "memory_kb": 77120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s646270995", "group_id": "codeNet:p02951", "input_text": "fun main(args: Array) {\n var (a,b,c) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(if (c - a + b >= 0)c-(a-b) else 0)\n}", "language": "Kotlin", "metadata": {"date": 1581016782, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02951/input.txt", "sample_output_relpath": "derived/input_output/data/p02951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02951/Kotlin/s646270995.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s646270995", "user_id": "u520434261"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n var (a,b,c) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(if (c - a + b >= 0)c-(a-b) else 0)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 142, "cpu_time_ms": 241, "memory_kb": 37824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s837434036", "group_id": "codeNet:p02951", "input_text": "fun main(args: Array) {\n\tval arr = readLine()!!.split(\" \")\n val a: Int = Integer.parseInt(arr[0])\n val b: Int = Integer.parseInt(arr[1])\n val c: Int = Integer.parseInt(arr[2])\n val ab: Int = a - b\n\tval ans: Int = c - ab\n\t// 出力\n\tprintln(Integer.toString(ans));\n}", "language": "Kotlin", "metadata": {"date": 1566859056, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02951/input.txt", "sample_output_relpath": "derived/input_output/data/p02951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02951/Kotlin/s837434036.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s837434036", "user_id": "u326261537"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n\tval arr = readLine()!!.split(\" \")\n val a: Int = Integer.parseInt(arr[0])\n val b: Int = Integer.parseInt(arr[1])\n val c: Int = Integer.parseInt(arr[2])\n val ab: Int = a - b\n\tval ans: Int = c - ab\n\t// 出力\n\tprintln(Integer.toString(ans));\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 285, "cpu_time_ms": 235, "memory_kb": 38036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s414707343", "group_id": "codeNet:p02951", "input_text": "fun main(args: Array) {\n\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(if (a <= b + c) c - a + b else 0)\n}", "language": "Kotlin", "metadata": {"date": 1564967005, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02951/input.txt", "sample_output_relpath": "derived/input_output/data/p02951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02951/Kotlin/s414707343.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414707343", "user_id": "u108272327"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(if (a <= b + c) c - a + b else 0)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 244, "memory_kb": 37756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s403316562", "group_id": "codeNet:p02952", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n\n var cnt = 0\n for (i in 1..n) {\n if (i.toString().length % 2 == 1) cnt++\n }\n\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1585913345, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02952/input.txt", "sample_output_relpath": "derived/input_output/data/p02952/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02952/Kotlin/s403316562.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403316562", "user_id": "u262403099"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n\n var cnt = 0\n for (i in 1..n) {\n if (i.toString().length % 2 == 1) cnt++\n }\n\n println(cnt)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "sample_input": "11\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02952", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 178, "cpu_time_ms": 255, "memory_kb": 38368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s133359952", "group_id": "codeNet:p02952", "input_text": "fun main(args: Array) {\n val input = readLine()!!.toInt()\n\n val ans = when (input.toString().length){\n 1 -> input\n 2 -> 9\n 3 -> input - 99 + 9\n 4 -> 909\n 5 -> input - 9999 + 909\n 6 -> 90909\n else -> 0\n }\n print(ans)\n}", "language": "Kotlin", "metadata": {"date": 1569117093, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02952/input.txt", "sample_output_relpath": "derived/input_output/data/p02952/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02952/Kotlin/s133359952.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133359952", "user_id": "u821053952"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()!!.toInt()\n\n val ans = when (input.toString().length){\n 1 -> input\n 2 -> 9\n 3 -> input - 99 + 9\n 4 -> 909\n 5 -> input - 9999 + 909\n 6 -> 90909\n else -> 0\n }\n print(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "sample_input": "11\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02952", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 202, "memory_kb": 31736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s396181422", "group_id": "codeNet:p02952", "input_text": "import java.util.*\n \nfun main(args: Array) {\n var num = readLine()!!\n\n when(num.length) {\n 1 -> {\n println(num.toInt())\n }\n 2 -> {\n println(9)\n }\n 3 -> {\n println(9 + num.toInt() - 99)\n }\n 4 -> {\n println(9 + 900)\n }\n 5 -> {\n println(9 + 900 + num.toInt() - 9999)\n }\n 6 -> {\n println(9 + 900 + 90000)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1564967647, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02952/input.txt", "sample_output_relpath": "derived/input_output/data/p02952/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02952/Kotlin/s396181422.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s396181422", "user_id": "u394420840"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n \nfun main(args: Array) {\n var num = readLine()!!\n\n when(num.length) {\n 1 -> {\n println(num.toInt())\n }\n 2 -> {\n println(9)\n }\n 3 -> {\n println(9 + num.toInt() - 99)\n }\n 4 -> {\n println(9 + 900)\n }\n 5 -> {\n println(9 + 900 + num.toInt() - 9999)\n }\n 6 -> {\n println(9 + 900 + 90000)\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "sample_input": "11\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02952", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 209, "memory_kb": 31700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s585656647", "group_id": "codeNet:p02955", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val aList = readLine()!!.split(\" \").map(String::toInt)\n val sumA = aList.sum()\n val max = aList.max()!!.plus(k)\n val modAList = (1..sumA).filter { sumA % it == 0 && it <= max }.reversed()\n println(modAList.joinToString(\" \"))\n\n for (mod in modAList) {\n val sortedAList = aList.map { it % mod }.filter { it % mod != 0 }.sorted().reversed().toMutableList()\n for (i in 0 until sortedAList.size) {\n sortedAList[i] -= mod\n if (sortedAList.sum() == 0 && sortedAList.filter { it > 0 }.sum() <= k) println(mod)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1566443995, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02955/input.txt", "sample_output_relpath": "derived/input_output/data/p02955/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02955/Kotlin/s585656647.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s585656647", "user_id": "u634493908"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n val aList = readLine()!!.split(\" \").map(String::toInt)\n val sumA = aList.sum()\n val max = aList.max()!!.plus(k)\n val modAList = (1..sumA).filter { sumA % it == 0 && it <= max }.reversed()\n println(modAList.joinToString(\" \"))\n\n for (mod in modAList) {\n val sortedAList = aList.map { it % mod }.filter { it % mod != 0 }.sorted().reversed().toMutableList()\n for (i in 0 until sortedAList.size) {\n sortedAList[i] -= mod\n if (sortedAList.sum() == 0 && sortedAList.filter { it > 0 }.sum() <= k) println(mod)\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "sample_input": "2 3\n8 20\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02955", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 667, "cpu_time_ms": 2111, "memory_kb": 118376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s931371059", "group_id": "codeNet:p02957", "input_text": "fun ans(a: Int, b: Int): Int {\n return (a + b) / 2\n}\n\nfun main(args: Array) {\n val n = readLine()!!.split(\" \")\n val a = n[0].toInt()\n val b = n[1].toInt()\n if ((a + b) % 2 == 1) {\n println(\"IMPOSSIBLE\")\n } else {\n println(ans(a, b))\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1569868482, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Kotlin/s931371059.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s931371059", "user_id": "u454524105"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun ans(a: Int, b: Int): Int {\n return (a + b) / 2\n}\n\nfun main(args: Array) {\n val n = readLine()!!.split(\" \")\n val a = n[0].toInt()\n val b = n[1].toInt()\n if ((a + b) % 2 == 1) {\n println(\"IMPOSSIBLE\")\n } else {\n println(ans(a, b))\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 234, "memory_kb": 37972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s765761802", "group_id": "codeNet:p02957", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n repeat (Math.pow(10.toDouble(), 9.toDouble()).toInt()){\n if (Math.abs(a-it).equals(Math.abs(b-it))) {\n println(it)\n return\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1565057036, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Kotlin/s765761802.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s765761802", "user_id": "u139478771"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n repeat (Math.pow(10.toDouble(), 9.toDouble()).toInt()){\n if (Math.abs(a-it).equals(Math.abs(b-it))) {\n println(it)\n return\n }\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 267, "cpu_time_ms": 2111, "memory_kb": 116928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s601903548", "group_id": "codeNet:p02957", "input_text": "/**\n * @author kojin15.\n */\nfun main(args: Array) {\n val (A, B) = readIntArrayH()\n if ((A + B) % 2 == 0) println((A + B) / 2) else println(\"IMPOSSIBLE\")\n}\n\n//in--------------------------------------------------------------------------------------------------------------------\nfun readInt(): Int = readLine()!!.toInt()\nfun readIntArrayH(): IntArray = readLine()!!.split(\" \").map(String::toInt)\n .let { IntArray(it.size) { n -> it[n] } }\nfun readIntArrayV(n: Int): IntArray = IntArray(n) { readInt() }\n\nfun readLong(): Long = readLine()!!.toLong()\nfun readLongArrayH(): LongArray = readLine()!!.split(\" \").map(String::toLong)\n .let { LongArray(it.size) { n -> it[n] } }\nfun readLongArrayV(n: Int): LongArray = LongArray(n) { readLong() }\n\n//out-------------------------------------------------------------------------------------------------------------------\nfun printBool(bool: Boolean, yes: String, no: String) = println(if (bool) yes else no)\nfun Boolean.print(yes: String, no: String) = printBool(this, yes, no)\n\nfun printYn(bool: Boolean) = printBool(bool, \"Yes\", \"No\")\nfun printYN(bool: Boolean) = printBool(bool, \"YES\", \"NO\")\nfun printPossible(bool: Boolean) = printBool(bool, \"Possible\", \"Impossible\")\nfun printYay(bool: Boolean) = printBool(bool, \"Yay!\", \":(\")\n\n//cast------------------------------------------------------------------------------------------------------------------\nfun int(n: Number) = n.toInt()\nfun long(n: Number) = n.toLong()\nfun double(n: Number) = n.toDouble()\nfun float(n: Number) = n.toFloat()\n\n//math------------------------------------------------------------------------------------------------------------------\ninfix fun Int.modP(mod: Int): Int {\n val y = this % mod\n return if (y < 0) y + mod else y\n}\n\ninfix fun Long.modP(mod: Int): Int {\n val y = int(this % mod)\n return if (y < 0) y + mod else y\n}\n\ninfix fun Int.pow(n: Int): Int = when {\n n == 0 -> 1\n n % 2 == 0 -> pow(n / 2).let { it * it }\n else -> this * pow(n - 1)\n}\n\nfun Int.powM(n: Int, m: Int): Int = when {\n n == 0 -> 1\n n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m\n else -> ((this % m) * (pow(n - 1) % m)) % m\n}\n\ninfix fun Long.pow(n: Int): Long = when {\n n == 0 -> 1\n n % 2 == 0 -> pow(n / 2).let { it * it }\n else -> this * pow(n - 1)\n}\n\nfun Long.powM(n: Int, m: Int): Long = when {\n n == 0 -> 1L\n n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m\n else -> ((this % m) * (pow(n - 1) % m)) % m\n}\n\nvar MOD: Int = 1000000007 //素数推奨\nclass ModInt(x: Int) {\n val x: Int = x modP MOD\n\n val mod: Int get() = MOD\n val inverse: ModInt get() = this.pow(MOD - 2)\n\n val factorial: ModInt get() = if (this > 0) this * (this - 1).factorial else ModInt(1)\n val doubleFactorial: ModInt get() = if (this > 1) this * (this - 2).doubleFactorial else ModInt(1)\n\n operator fun unaryMinus(): ModInt = ModInt(-x)\n\n operator fun inc(): ModInt = ModInt(x + 1)\n operator fun dec(): ModInt = ModInt(x - 1)\n\n operator fun plus(other: ModInt): ModInt = ModInt(x + other.x)\n operator fun plus(other: Int): ModInt = this.plus(ModInt(other))\n\n operator fun minus(other: ModInt): ModInt = this + (-other)\n operator fun minus(other: Int): ModInt = this.minus(ModInt(other))\n\n operator fun times(other: ModInt): ModInt = ModInt(x * other.x)\n operator fun times(other: Int): ModInt = this.times(ModInt(other))\n\n operator fun div(other: ModInt): ModInt = this * other.inverse\n operator fun div(other: Int): ModInt = this.div(ModInt(other))\n\n operator fun mod(other: ModInt): ModInt = ModInt(x modP other.x)\n operator fun mod(other: Int): ModInt = this.mod(ModInt(other))\n\n infix fun pow(n: Int): ModInt = ModInt(this.x.powM(n, MOD))\n\n operator fun compareTo(other: ModInt) = this.x.compareTo(other.x)\n operator fun compareTo(other: Int) = this.compareTo(ModInt(other))\n\n override operator fun equals(other: Any?): Boolean {\n if (other is ModInt) return this.x == other.x\n return this.x == other\n }\n\n override fun hashCode(): Int {\n return x\n }\n\n override fun toString(): String {\n return this.x.toString()\n }\n}\noperator fun Int.plus(other: ModInt): ModInt = ModInt(this).plus(other)\noperator fun Int.minus(other: ModInt): ModInt = ModInt(this).minus(other)\noperator fun Int.times(other: ModInt): ModInt = ModInt(this).times(other)\noperator fun Int.div(other: ModInt): ModInt = ModInt(this).div(other)\noperator fun Int.mod(other: ModInt): ModInt = ModInt(this).mod(other)\noperator fun Int.compareTo(other: ModInt) = ModInt(this).compareTo(other)", "language": "Kotlin", "metadata": {"date": 1564778102, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Kotlin/s601903548.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601903548", "user_id": "u771276989"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "/**\n * @author kojin15.\n */\nfun main(args: Array) {\n val (A, B) = readIntArrayH()\n if ((A + B) % 2 == 0) println((A + B) / 2) else println(\"IMPOSSIBLE\")\n}\n\n//in--------------------------------------------------------------------------------------------------------------------\nfun readInt(): Int = readLine()!!.toInt()\nfun readIntArrayH(): IntArray = readLine()!!.split(\" \").map(String::toInt)\n .let { IntArray(it.size) { n -> it[n] } }\nfun readIntArrayV(n: Int): IntArray = IntArray(n) { readInt() }\n\nfun readLong(): Long = readLine()!!.toLong()\nfun readLongArrayH(): LongArray = readLine()!!.split(\" \").map(String::toLong)\n .let { LongArray(it.size) { n -> it[n] } }\nfun readLongArrayV(n: Int): LongArray = LongArray(n) { readLong() }\n\n//out-------------------------------------------------------------------------------------------------------------------\nfun printBool(bool: Boolean, yes: String, no: String) = println(if (bool) yes else no)\nfun Boolean.print(yes: String, no: String) = printBool(this, yes, no)\n\nfun printYn(bool: Boolean) = printBool(bool, \"Yes\", \"No\")\nfun printYN(bool: Boolean) = printBool(bool, \"YES\", \"NO\")\nfun printPossible(bool: Boolean) = printBool(bool, \"Possible\", \"Impossible\")\nfun printYay(bool: Boolean) = printBool(bool, \"Yay!\", \":(\")\n\n//cast------------------------------------------------------------------------------------------------------------------\nfun int(n: Number) = n.toInt()\nfun long(n: Number) = n.toLong()\nfun double(n: Number) = n.toDouble()\nfun float(n: Number) = n.toFloat()\n\n//math------------------------------------------------------------------------------------------------------------------\ninfix fun Int.modP(mod: Int): Int {\n val y = this % mod\n return if (y < 0) y + mod else y\n}\n\ninfix fun Long.modP(mod: Int): Int {\n val y = int(this % mod)\n return if (y < 0) y + mod else y\n}\n\ninfix fun Int.pow(n: Int): Int = when {\n n == 0 -> 1\n n % 2 == 0 -> pow(n / 2).let { it * it }\n else -> this * pow(n - 1)\n}\n\nfun Int.powM(n: Int, m: Int): Int = when {\n n == 0 -> 1\n n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m\n else -> ((this % m) * (pow(n - 1) % m)) % m\n}\n\ninfix fun Long.pow(n: Int): Long = when {\n n == 0 -> 1\n n % 2 == 0 -> pow(n / 2).let { it * it }\n else -> this * pow(n - 1)\n}\n\nfun Long.powM(n: Int, m: Int): Long = when {\n n == 0 -> 1L\n n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m\n else -> ((this % m) * (pow(n - 1) % m)) % m\n}\n\nvar MOD: Int = 1000000007 //素数推奨\nclass ModInt(x: Int) {\n val x: Int = x modP MOD\n\n val mod: Int get() = MOD\n val inverse: ModInt get() = this.pow(MOD - 2)\n\n val factorial: ModInt get() = if (this > 0) this * (this - 1).factorial else ModInt(1)\n val doubleFactorial: ModInt get() = if (this > 1) this * (this - 2).doubleFactorial else ModInt(1)\n\n operator fun unaryMinus(): ModInt = ModInt(-x)\n\n operator fun inc(): ModInt = ModInt(x + 1)\n operator fun dec(): ModInt = ModInt(x - 1)\n\n operator fun plus(other: ModInt): ModInt = ModInt(x + other.x)\n operator fun plus(other: Int): ModInt = this.plus(ModInt(other))\n\n operator fun minus(other: ModInt): ModInt = this + (-other)\n operator fun minus(other: Int): ModInt = this.minus(ModInt(other))\n\n operator fun times(other: ModInt): ModInt = ModInt(x * other.x)\n operator fun times(other: Int): ModInt = this.times(ModInt(other))\n\n operator fun div(other: ModInt): ModInt = this * other.inverse\n operator fun div(other: Int): ModInt = this.div(ModInt(other))\n\n operator fun mod(other: ModInt): ModInt = ModInt(x modP other.x)\n operator fun mod(other: Int): ModInt = this.mod(ModInt(other))\n\n infix fun pow(n: Int): ModInt = ModInt(this.x.powM(n, MOD))\n\n operator fun compareTo(other: ModInt) = this.x.compareTo(other.x)\n operator fun compareTo(other: Int) = this.compareTo(ModInt(other))\n\n override operator fun equals(other: Any?): Boolean {\n if (other is ModInt) return this.x == other.x\n return this.x == other\n }\n\n override fun hashCode(): Int {\n return x\n }\n\n override fun toString(): String {\n return this.x.toString()\n }\n}\noperator fun Int.plus(other: ModInt): ModInt = ModInt(this).plus(other)\noperator fun Int.minus(other: ModInt): ModInt = ModInt(this).minus(other)\noperator fun Int.times(other: ModInt): ModInt = ModInt(this).times(other)\noperator fun Int.div(other: ModInt): ModInt = ModInt(this).div(other)\noperator fun Int.mod(other: ModInt): ModInt = ModInt(this).mod(other)\noperator fun Int.compareTo(other: ModInt) = ModInt(this).compareTo(other)", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4604, "cpu_time_ms": 234, "memory_kb": 35988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s687616594", "group_id": "codeNet:p02957", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val input = listOfInt()\n \tval a = input[0]\n \tval b = input[1]\n if((a%2==0 && b%2!=0) || (a%2!=0 && b%2==0)){\n println(\"IMPOSSIBLE\")\n }else{\n if(a%2!=0){\n println(a/2+b/2+1);\n }else{\n println(a/2+b/2);\n }\n }\n}\n\n// 入力取得\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\nfun println(value : Any) {\n pw.println(value)\n}\n", "language": "Kotlin", "metadata": {"date": 1564276092, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Kotlin/s687616594.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687616594", "user_id": "u957679320"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val input = listOfInt()\n \tval a = input[0]\n \tval b = input[1]\n if((a%2==0 && b%2!=0) || (a%2!=0 && b%2==0)){\n println(\"IMPOSSIBLE\")\n }else{\n if(a%2!=0){\n println(a/2+b/2+1);\n }else{\n println(a/2+b/2);\n }\n }\n}\n\n// 入力取得\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\nfun println(value : Any) {\n pw.println(value)\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 789, "cpu_time_ms": 237, "memory_kb": 37904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s601115265", "group_id": "codeNet:p02958", "input_text": "fun main(argas: Array) {\n val n = readLine()!!.toInt()\n val values = readLine()!!.split(\" \").map(String::toInt)\n\n var pairs = mutableListOf>();\n\n for (i in 0 until n-1) {\n if (values[i] > values[i+1]) {\n pairs.add(Pair(i, values[i]))\n break\n }\n }\n\n for (j in n-1 downTo 1) {\n if (values[j] < values[j-1]) {\n pairs.add(Pair(j, values[j]))\n break\n }\n }\n\n if (pairs.size != 2) {\n println(\"YES\")\n return\n }\n\n var a = pairs.first()\n var b = pairs.last()\n\n if (a.second >= values[b.first-1] && b.second <= values[a.first+1]) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1564880720, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02958/input.txt", "sample_output_relpath": "derived/input_output/data/p02958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02958/Kotlin/s601115265.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s601115265", "user_id": "u004938108"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(argas: Array) {\n val n = readLine()!!.toInt()\n val values = readLine()!!.split(\" \").map(String::toInt)\n\n var pairs = mutableListOf>();\n\n for (i in 0 until n-1) {\n if (values[i] > values[i+1]) {\n pairs.add(Pair(i, values[i]))\n break\n }\n }\n\n for (j in n-1 downTo 1) {\n if (values[j] < values[j-1]) {\n pairs.add(Pair(j, values[j]))\n break\n }\n }\n\n if (pairs.size != 2) {\n println(\"YES\")\n return\n }\n\n var a = pairs.first()\n var b = pairs.last()\n\n if (a.second >= values[b.first-1] && b.second <= values[a.first+1]) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 731, "cpu_time_ms": 253, "memory_kb": 38164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s742146184", "group_id": "codeNet:p02959", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val b = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n var ans = 0\n ans += Math.min(a[0], b[0])\n b[0] = if (a[0] <= b[0]) b[0] - a[0] else 0\n for (i in 0 until n) {\n if (i == n-1) {\n return println(ans + Math.min(a[i+1], b[i]))\n } else {\n ans += Math.min(a[i+1], b[i]+b[i+1])\n b[i+1] = if (a[i+1] <= b[i] + b[i+1]) Math.min(b[i] + b[i+1] - a[i+1], b[i+1]) else 0\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1575511672, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/Kotlin/s742146184.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s742146184", "user_id": "u396701320"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val b = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n var ans = 0\n ans += Math.min(a[0], b[0])\n b[0] = if (a[0] <= b[0]) b[0] - a[0] else 0\n for (i in 0 until n) {\n if (i == n-1) {\n return println(ans + Math.min(a[i+1], b[i]))\n } else {\n ans += Math.min(a[i+1], b[i]+b[i+1])\n b[i+1] = if (a[i+1] <= b[i] + b[i+1]) Math.min(b[i] + b[i+1] - a[i+1], b[i+1]) else 0\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 577, "cpu_time_ms": 737, "memory_kb": 82288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s779979787", "group_id": "codeNet:p02959", "input_text": "fun main(args: Array) {\n val heroCount = readLine()!!.toInt()\n val monsterCountParTown = readLine()!!.split(\" \").map { it.toInt() }\n val maxKillCountParHero = readLine()!!.split(\" \").map { it.toInt() }\n\n print(abc135c(heroCount, monsterCountParTown, maxKillCountParHero))\n}\n\nfun abc135c(heroCount: Int, monsterCountParTown: List, maxKillCountParHero: List): Long {\n var ans:Long = 0\n val monsterCount = mutableMapOf()\n for(i in monsterCountParTown.indices){\n monsterCount[i] = monsterCountParTown[i]\n }\n\n //協力が出来ていない?\n // 必ず前の街を全力で潰す。二つ目の全力にするパターンもある?\n for (i in 1..heroCount) {\n val target: Pair = Pair(monsterCount[i - 1]!!, monsterCount[i]!!)\n val attackResult = attackMonster(target, maxKillCountParHero[i - 1])\n ans += attackResult.first\n monsterCount[i - 1] = attackResult.second\n monsterCount[i] = attackResult.third\n }\n return ans\n}\n\nfun attackMonster(target: Pair, maxKillCount: Int): Triple {\n\n var firstTownMonsterCount = target.first\n var secondTownMonsterCount = target.second\n var killCount:Int\n\n //最初の街を攻撃\n when {\n firstTownMonsterCount > maxKillCount -> { //全部殺せない場合\n killCount = maxKillCount\n firstTownMonsterCount -= killCount\n\n return Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)\n }\n else -> {\n killCount = firstTownMonsterCount\n firstTownMonsterCount = 0\n }\n }\n\n //次の街を攻撃\n return when {\n secondTownMonsterCount > (maxKillCount - killCount) -> { //全部殺せない場合\n secondTownMonsterCount -= (maxKillCount - killCount)\n killCount = maxKillCount\n Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)\n }\n else ->{\n killCount += secondTownMonsterCount\n secondTownMonsterCount = 0\n Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1569227581, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/Kotlin/s779979787.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s779979787", "user_id": "u821053952"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val heroCount = readLine()!!.toInt()\n val monsterCountParTown = readLine()!!.split(\" \").map { it.toInt() }\n val maxKillCountParHero = readLine()!!.split(\" \").map { it.toInt() }\n\n print(abc135c(heroCount, monsterCountParTown, maxKillCountParHero))\n}\n\nfun abc135c(heroCount: Int, monsterCountParTown: List, maxKillCountParHero: List): Long {\n var ans:Long = 0\n val monsterCount = mutableMapOf()\n for(i in monsterCountParTown.indices){\n monsterCount[i] = monsterCountParTown[i]\n }\n\n //協力が出来ていない?\n // 必ず前の街を全力で潰す。二つ目の全力にするパターンもある?\n for (i in 1..heroCount) {\n val target: Pair = Pair(monsterCount[i - 1]!!, monsterCount[i]!!)\n val attackResult = attackMonster(target, maxKillCountParHero[i - 1])\n ans += attackResult.first\n monsterCount[i - 1] = attackResult.second\n monsterCount[i] = attackResult.third\n }\n return ans\n}\n\nfun attackMonster(target: Pair, maxKillCount: Int): Triple {\n\n var firstTownMonsterCount = target.first\n var secondTownMonsterCount = target.second\n var killCount:Int\n\n //最初の街を攻撃\n when {\n firstTownMonsterCount > maxKillCount -> { //全部殺せない場合\n killCount = maxKillCount\n firstTownMonsterCount -= killCount\n\n return Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)\n }\n else -> {\n killCount = firstTownMonsterCount\n firstTownMonsterCount = 0\n }\n }\n\n //次の街を攻撃\n return when {\n secondTownMonsterCount > (maxKillCount - killCount) -> { //全部殺せない場合\n secondTownMonsterCount -= (maxKillCount - killCount)\n killCount = maxKillCount\n Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)\n }\n else ->{\n killCount += secondTownMonsterCount\n secondTownMonsterCount = 0\n Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2205, "cpu_time_ms": 974, "memory_kb": 96500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s493796921", "group_id": "codeNet:p02959", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val monsNum = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n val hp = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n\n var sum = 0\n for (i in 0 until N) {\n if (hp[i] > monsNum[i]) {\n if (hp[i] > monsNum[i] + monsNum[i+1]) {\n sum += monsNum[i] + monsNum[i+1]\n monsNum[i+1] = 0\n } else {\n sum += hp[i]\n monsNum[i+1] -= hp[i] - monsNum[i]\n }\n } else {\n sum += hp[i]\n }\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1565055784, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/Kotlin/s493796921.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s493796921", "user_id": "u388719350"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val monsNum = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n val hp = readLine()!!.split(\" \").map { it.toInt() }.toMutableList()\n\n var sum = 0\n for (i in 0 until N) {\n if (hp[i] > monsNum[i]) {\n if (hp[i] > monsNum[i] + monsNum[i+1]) {\n sum += monsNum[i] + monsNum[i+1]\n monsNum[i+1] = 0\n } else {\n sum += hp[i]\n monsNum[i+1] -= hp[i] - monsNum[i]\n }\n } else {\n sum += hp[i]\n }\n }\n println(sum)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 536, "cpu_time_ms": 747, "memory_kb": 84340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s083356804", "group_id": "codeNet:p02959", "input_text": "import java.util.*\n\nfun main(vararg args: String) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val monsters = IntArray(n + 1)\n repeat(n + 1) {\n monsters[it] = scanner.nextInt()\n }\n val bullets = IntArray(n)\n repeat(n) {\n bullets[it] = scanner.nextInt()\n }\n\n var kills = 0\n for (i in 0 until n) {\n val m = monsters[i]\n val b = bullets[i]\n val overkills = b - m\n if (overkills <= 0) {\n kills += b\n } else {\n // overkills > 0\n kills += m\n val nextm = monsters[i + 1]\n if (overkills == nextm) kills += nextm\n if (overkills > nextm) kills += nextm\n if (overkills < nextm) kills += overkills\n monsters[i + 1] = Math.max(0, nextm - overkills)\n }\n }\n println(kills)\n}\n", "language": "Kotlin", "metadata": {"date": 1564876814, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/Kotlin/s083356804.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s083356804", "user_id": "u329692035"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*\n\nfun main(vararg args: String) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val monsters = IntArray(n + 1)\n repeat(n + 1) {\n monsters[it] = scanner.nextInt()\n }\n val bullets = IntArray(n)\n repeat(n) {\n bullets[it] = scanner.nextInt()\n }\n\n var kills = 0\n for (i in 0 until n) {\n val m = monsters[i]\n val b = bullets[i]\n val overkills = b - m\n if (overkills <= 0) {\n kills += b\n } else {\n // overkills > 0\n kills += m\n val nextm = monsters[i + 1]\n if (overkills == nextm) kills += nextm\n if (overkills > nextm) kills += nextm\n if (overkills < nextm) kills += overkills\n monsters[i + 1] = Math.max(0, nextm - overkills)\n }\n }\n println(kills)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 861, "cpu_time_ms": 631, "memory_kb": 69264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s260610153", "group_id": "codeNet:p02960", "input_text": "fun main(argc:Array){\n val MOD = 1000000007L;\n\n val S = readLine()!!\n var dp = Array(10005, {i->Array(13, {i->0L})})\n dp[0][0] = 1\n\n for (i in 0..S.length-1){\n var c = 0\n if (S[i] == '?') {\n c = -1\n }\n else {\n c = S[i].toString().toInt()\n }\n\n for (j in 0..9){\n if (c != -1 && c != j){\n continue\n }\n for (ki in 0..12){\n dp[i+1][(ki*10+j) % 13] += dp[i][ki]\n }\n }\n for (j in 1..12){\n dp[i+1][j] %= MOD\n }\n }\n \n println(dp[S.length][5])\n}\n", "language": "Kotlin", "metadata": {"date": 1565752306, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02960.html", "problem_id": "p02960", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02960/input.txt", "sample_output_relpath": "derived/input_output/data/p02960/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02960/Kotlin/s260610153.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s260610153", "user_id": "u625554679"}, "prompt_components": {"gold_output": "768\n", "input_to_evaluate": "fun main(argc:Array){\n val MOD = 1000000007L;\n\n val S = readLine()!!\n var dp = Array(10005, {i->Array(13, {i->0L})})\n dp[0][0] = 1\n\n for (i in 0..S.length-1){\n var c = 0\n if (S[i] == '?') {\n c = -1\n }\n else {\n c = S[i].toString().toInt()\n }\n\n for (j in 0..9){\n if (c != -1 && c != j){\n continue\n }\n for (ki in 0..12){\n dp[i+1][(ki*10+j) % 13] += dp[i][ki]\n }\n }\n for (j in 1..12){\n dp[i+1][j] %= MOD\n }\n }\n \n println(dp[S.length][5])\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "sample_input": "??2??5\n"}, "reference_outputs": ["768\n"], "source_document_id": "p02960", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 636, "cpu_time_ms": 314, "memory_kb": 50368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s508270874", "group_id": "codeNet:p02963", "input_text": "import java.util.NoSuchElementException\nimport java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val S = scanner.nextLong()\n //val S = 1000000000000000001\n val ad = S\n // ad - bc = S\n var i = (Math.sqrt(ad.toDouble())).toLong()\n var a = 0L\n var d = 0L\n while (i >= 1) {\n if (ad % i == 0L) {\n a = i\n d = ad/ i\n break\n }\n i--\n }\n println(\"0 0 \" + a.toString() + \" 1 0 \" + d.toString())\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -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 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 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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1563766450, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Kotlin/s508270874.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s508270874", "user_id": "u465133507"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "import java.util.NoSuchElementException\nimport java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val S = scanner.nextLong()\n //val S = 1000000000000000001\n val ad = S\n // ad - bc = S\n var i = (Math.sqrt(ad.toDouble())).toLong()\n var a = 0L\n var d = 0L\n while (i >= 1) {\n if (ad % i == 0L) {\n a = i\n d = ad/ i\n break\n }\n i--\n }\n println(\"0 0 \" + a.toString() + \" 1 0 \" + d.toString())\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -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 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 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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2500, "cpu_time_ms": 2111, "memory_kb": 31388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s708607561", "group_id": "codeNet:p02963", "input_text": "import java.util.NoSuchElementException\nimport java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val S = scanner.nextLong()\n //val S = 1000000000000000001\n val ad = S + 1L\n // ad - bc = S\n var i = (Math.sqrt(ad.toDouble())).toLong()\n var a = 0L\n var d = 0L\n while (i >= 1) {\n if (ad % i == 0L) {\n a = i\n d = ad/ i\n break\n }\n i--\n }\n println(\"0 0 \" + a.toString() + \" 1 1 \" + d.toString())\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -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 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 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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1563766078, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Kotlin/s708607561.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s708607561", "user_id": "u465133507"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "import java.util.NoSuchElementException\nimport java.io.IOException\n\nfun main(args : Array) {\n val scanner = FastScanner()\n val S = scanner.nextLong()\n //val S = 1000000000000000001\n val ad = S + 1L\n // ad - bc = S\n var i = (Math.sqrt(ad.toDouble())).toLong()\n var a = 0L\n var d = 0L\n while (i >= 1) {\n if (ad % i == 0L) {\n a = i\n d = ad/ i\n break\n }\n i--\n }\n println(\"0 0 \" + a.toString() + \" 1 1 \" + d.toString())\n}\n\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -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 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 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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2505, "cpu_time_ms": 2111, "memory_kb": 31392}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s275578858", "group_id": "codeNet:p02963", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val s = nextLong()\n var r = Math.sqrt(s.toDouble()).toLong()\n\n if (r * r == s) {\n println(\"0 0 $r 0 0 $r\")\n return\n }\n\n for (i in 1..r-1) {\n if (s % (r+i) == 0L) {\n val w = r+i\n val h = s / (r+i)\n println(\"0 0 $w 0 0 $h\")\n return\n }\n if (s % (r-i) == 0L) {\n val w = r-i\n val h = s / (r-i)\n println(\"0 0 $w 0 0 $h\")\n return\n }\n } \n\n println(\"0 0 1 0 0 $s\")\n}\n\nfun next() = readLine()!!\nfun nextLong() = next().toLong()\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1563763127, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Kotlin/s275578858.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s275578858", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val s = nextLong()\n var r = Math.sqrt(s.toDouble()).toLong()\n\n if (r * r == s) {\n println(\"0 0 $r 0 0 $r\")\n return\n }\n\n for (i in 1..r-1) {\n if (s % (r+i) == 0L) {\n val w = r+i\n val h = s / (r+i)\n println(\"0 0 $w 0 0 $h\")\n return\n }\n if (s % (r-i) == 0L) {\n val w = r-i\n val h = s / (r-i)\n println(\"0 0 $w 0 0 $h\")\n return\n }\n } \n\n println(\"0 0 1 0 0 $s\")\n}\n\nfun next() = readLine()!!\nfun nextLong() = next().toLong()\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 760, "cpu_time_ms": 2111, "memory_kb": 33612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s180535714", "group_id": "codeNet:p02969", "input_text": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n println(3 * (r * r))\n}", "language": "Kotlin", "metadata": {"date": 1592339412, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02969.html", "problem_id": "p02969", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02969/input.txt", "sample_output_relpath": "derived/input_output/data/p02969/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02969/Kotlin/s180535714.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180535714", "user_id": "u724021453"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "fun main(args: Array) {\n val r = readLine()!!.toInt()\n println(3 * (r * r))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 91, "cpu_time_ms": 204, "memory_kb": 29848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s658982299", "group_id": "codeNet:p02969", "input_text": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n\n println(3*x*x)\n}", "language": "Kotlin", "metadata": {"date": 1563670871, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02969.html", "problem_id": "p02969", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02969/input.txt", "sample_output_relpath": "derived/input_output/data/p02969/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02969/Kotlin/s658982299.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658982299", "user_id": "u889750959"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n\n println(3*x*x)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 207, "memory_kb": 31612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s347089337", "group_id": "codeNet:p02970", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextInt()\n \tval d = nextInt()\n \tval onePerson = 2*d+1\n \tval ans = n/onePerson\n \tif(ans*onePerson < n){\n println(ans + 1)\n }else{\n println(ans)\n }\n}\n\n// 入力取得\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}\n", "language": "Kotlin", "metadata": {"date": 1563671445, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02970.html", "problem_id": "p02970", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02970/input.txt", "sample_output_relpath": "derived/input_output/data/p02970/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02970/Kotlin/s347089337.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s347089337", "user_id": "u957679320"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextInt()\n \tval d = nextInt()\n \tval onePerson = 2*d+1\n \tval ans = n/onePerson\n \tif(ans*onePerson < n){\n println(ans + 1)\n }else{\n println(ans)\n }\n}\n\n// 入力取得\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N apple trees in a row. People say that one of them will bear golden apples.\n\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\n\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \\leq i \\leq N) will inspect the trees with numbers between i-D and i+D (inclusive).\n\nFind the minimum number of inspectors that we need to deploy to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq D \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\n\nOutput\n\nPrint the minimum number of inspectors that we need to deploy to achieve the objective.\n\nSample Input 1\n\n6 2\n\nSample Output 1\n\n2\n\nWe can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.\n\nSample Input 2\n\n14 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n20 4\n\nSample Output 3\n\n3", "sample_input": "6 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02970", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N apple trees in a row. People say that one of them will bear golden apples.\n\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\n\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \\leq i \\leq N) will inspect the trees with numbers between i-D and i+D (inclusive).\n\nFind the minimum number of inspectors that we need to deploy to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq D \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\n\nOutput\n\nPrint the minimum number of inspectors that we need to deploy to achieve the objective.\n\nSample Input 1\n\n6 2\n\nSample Output 1\n\n2\n\nWe can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.\n\nSample Input 2\n\n14 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n20 4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1836, "cpu_time_ms": 206, "memory_kb": 31644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s634625235", "group_id": "codeNet:p02971", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }.toIntArray()\n\n val array = Array(n) { Array(n) { a[it] } }\n\n val ans = mutableListOf()\n for (i in 0 until n) {\n array[i][i] = 0\n val max = array[i].max()!!\n ans.add(max)\n }\n\n println(ans.joinToString(\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1590931109, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Kotlin/s634625235.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s634625235", "user_id": "u323522006"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }.toIntArray()\n\n val array = Array(n) { Array(n) { a[it] } }\n\n val ans = mutableListOf()\n for (i in 0 until n) {\n array[i][i] = 0\n val max = array[i].max()!!\n ans.add(max)\n }\n\n println(ans.joinToString(\"\\n\"))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 373, "cpu_time_ms": 2119, "memory_kb": 261644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s941635777", "group_id": "codeNet:p02971", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n val array = Array(n) { Array(n) { a.get(it) } }\n\n val ans = mutableListOf()\n for (i in 0 until n) {\n array[i][i] = 0\n val max = array[i].max()!!\n ans.add(max)\n }\n\n println(ans.joinToString(\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1590931033, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Kotlin/s941635777.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s941635777", "user_id": "u323522006"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n val array = Array(n) { Array(n) { a.get(it) } }\n\n val ans = mutableListOf()\n for (i in 0 until n) {\n array[i][i] = 0\n val max = array[i].max()!!\n ans.add(max)\n }\n\n println(ans.joinToString(\"\\n\"))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 364, "cpu_time_ms": 2119, "memory_kb": 264424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s158542449", "group_id": "codeNet:p02971", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var list = Array(n){0}\n for (i in 0 until n) {\n list[i] = readLine()!!.toInt()\n }\n val sorted = list.sorted()\n for (i in 0 until n) {\n if (list[i] == sorted[n-1]) println(sorted[n-2])\n else println(sorted[n-1])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1575690009, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Kotlin/s158542449.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s158542449", "user_id": "u396701320"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var list = Array(n){0}\n for (i in 0 until n) {\n list[i] = readLine()!!.toInt()\n }\n val sorted = list.sorted()\n for (i in 0 until n) {\n if (list[i] == sorted[n-1]) println(sorted[n-2])\n else println(sorted[n-1])\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 1735, "memory_kb": 57104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s189855384", "group_id": "codeNet:p02971", "input_text": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n val a = (1..n).map { readLine()!!.toInt() }.toTypedArray()\n\n val initMax = a.max()!!\n\n for (i in 0 until n) {\n if (a[i] < initMax) {\n println(initMax)\n } else {\n val temp = a.copyOf()\n temp[i] = 0\n val tempMax = temp.max()!!\n println(tempMax)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1564241843, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Kotlin/s189855384.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s189855384", "user_id": "u108272327"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n val a = (1..n).map { readLine()!!.toInt() }.toTypedArray()\n\n val initMax = a.max()!!\n\n for (i in 0 until n) {\n if (a[i] < initMax) {\n println(initMax)\n } else {\n val temp = a.copyOf()\n temp[i] = 0\n val tempMax = temp.max()!!\n println(tempMax)\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 406, "cpu_time_ms": 2111, "memory_kb": 123912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s927627219", "group_id": "codeNet:p02971", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val numbers = mutableListOf()\n for (i in 0 until n) {\n numbers.add(readLine()!!.toInt())\n }\n\n val maxNumber = numbers.fold(initial = 0, operation = { a, b -> Math.max(a,b)})\n val maxNumberCount = numbers.filter { it == maxNumber }.size\n\n val sortedNumbers = numbers.sorted().reversed()\n\n for (i in 0 until n) {\n if (numbers[i] < maxNumber) {\n println(maxNumber)\n } else if (numbers[i] == maxNumber){\n if (maxNumberCount > 1) {\n println(maxNumber)\n } else {\n println(sortedNumbers[1])\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1563673201, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Kotlin/s927627219.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s927627219", "user_id": "u712335892"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val numbers = mutableListOf()\n for (i in 0 until n) {\n numbers.add(readLine()!!.toInt())\n }\n\n val maxNumber = numbers.fold(initial = 0, operation = { a, b -> Math.max(a,b)})\n val maxNumberCount = numbers.filter { it == maxNumber }.size\n\n val sortedNumbers = numbers.sorted().reversed()\n\n for (i in 0 until n) {\n if (numbers[i] < maxNumber) {\n println(maxNumber)\n } else if (numbers[i] == maxNumber){\n if (maxNumberCount > 1) {\n println(maxNumber)\n } else {\n println(sortedNumbers[1])\n }\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 691, "cpu_time_ms": 1741, "memory_kb": 61548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s878306982", "group_id": "codeNet:p02972", "input_text": "fun main() {\n abc134d()\n}\n\nfun abc134d() {\n val n = readLine()!!.toInt()\n // 各桁について、1ならiの倍数が奇数個になるようにするという意味\n val a = BooleanArray(n + 1) { false }\n for ((i, s) in readLine()!!.split(\" \").withIndex()) {\n a[i + 1] = s == \"1\"\n }\n val ans = mutableSetOf()\n var i = n\n var depth = 0\n while (i > 1) {\n var j = i\n while (j * 2 > i) {\n val k = j * 2\n if (k <= n) {\n var count = 0\n for (l in 1..depth) {\n if (a[l]) count++\n }\n val isOdd = count % 2 == 1\n if (isOdd xor a[j]) ans.add(j)\n } else {\n if (a[j]) ans.add(j)\n }\n j--\n }\n i = j\n depth++\n }\n if (a[1]) {\n if (ans.size % 2 == 0) ans.add(1)\n } else {\n if (ans.size % 2 == 1) ans.add(1)\n }\n println(ans.size)\n println(ans.joinToString(\" \"))\n}", "language": "Kotlin", "metadata": {"date": 1593985749, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02972.html", "problem_id": "p02972", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02972/input.txt", "sample_output_relpath": "derived/input_output/data/p02972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02972/Kotlin/s878306982.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s878306982", "user_id": "u628907033"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "fun main() {\n abc134d()\n}\n\nfun abc134d() {\n val n = readLine()!!.toInt()\n // 各桁について、1ならiの倍数が奇数個になるようにするという意味\n val a = BooleanArray(n + 1) { false }\n for ((i, s) in readLine()!!.split(\" \").withIndex()) {\n a[i + 1] = s == \"1\"\n }\n val ans = mutableSetOf()\n var i = n\n var depth = 0\n while (i > 1) {\n var j = i\n while (j * 2 > i) {\n val k = j * 2\n if (k <= n) {\n var count = 0\n for (l in 1..depth) {\n if (a[l]) count++\n }\n val isOdd = count % 2 == 1\n if (isOdd xor a[j]) ans.add(j)\n } else {\n if (a[j]) ans.add(j)\n }\n j--\n }\n i = j\n depth++\n }\n if (a[1]) {\n if (ans.size % 2 == 0) ans.add(1)\n } else {\n if (ans.size % 2 == 1) ans.add(1)\n }\n println(ans.size)\n println(ans.joinToString(\" \"))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "sample_input": "3\n1 0 0\n"}, "reference_outputs": ["1\n1\n"], "source_document_id": "p02972", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1019, "cpu_time_ms": 463, "memory_kb": 66912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s453959037", "group_id": "codeNet:p02972", "input_text": "fun main(args: Array) {\n abc134d()\n}\n\nfun abc134d() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(\" \")\n .map { it == \"0\" }\n\n val ballInBoxes = BooleanArray(n)\n\n (n - 1 downTo 0).forEach { index ->\n var currAi = index + 1\n var sumModIsZero = true\n while ((currAi - 1) < n) {\n if (ballInBoxes[currAi - 1]) sumModIsZero = !sumModIsZero\n currAi += (index + 1)\n }\n\n if (aList[index] != sumModIsZero) ballInBoxes[index] = true\n }\n\n val count = ballInBoxes.count { it }\n println(count)\n\n if (count > 0) {\n println(ballInBoxes.withIndex().filter { it.value }.map { it.index + 1 }.joinToString(\" \"))\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1573341293, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02972.html", "problem_id": "p02972", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02972/input.txt", "sample_output_relpath": "derived/input_output/data/p02972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02972/Kotlin/s453959037.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453959037", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "fun main(args: Array) {\n abc134d()\n}\n\nfun abc134d() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(\" \")\n .map { it == \"0\" }\n\n val ballInBoxes = BooleanArray(n)\n\n (n - 1 downTo 0).forEach { index ->\n var currAi = index + 1\n var sumModIsZero = true\n while ((currAi - 1) < n) {\n if (ballInBoxes[currAi - 1]) sumModIsZero = !sumModIsZero\n currAi += (index + 1)\n }\n\n if (aList[index] != sumModIsZero) ballInBoxes[index] = true\n }\n\n val count = ballInBoxes.count { it }\n println(count)\n\n if (count > 0) {\n println(ballInBoxes.withIndex().filter { it.value }.map { it.index + 1 }.joinToString(\" \"))\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "sample_input": "3\n1 0 0\n"}, "reference_outputs": ["1\n1\n"], "source_document_id": "p02972", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 723, "cpu_time_ms": 799, "memory_kb": 79856}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s229106115", "group_id": "codeNet:p02973", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val aa = IntArray(n) { readLine()!!.toInt() }\n val palette = mutableListOf()\n var color = 0\n palette.add(aa[0])\n repeat(n - 1) {\n val a1 = aa[it]\n val a2 = aa[it + 1]\n if (a1 < a2) {\n palette[color] = a2\n return@repeat\n }\n palette.forEachIndexed { i, c ->\n if (i == color) return@forEachIndexed\n if (c < a2) {\n color = i\n palette[color] = a2\n return@repeat\n }\n }\n palette.add(a2)\n color = palette.size - 1\n }\n println(palette.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1563674632, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02973.html", "problem_id": "p02973", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02973/input.txt", "sample_output_relpath": "derived/input_output/data/p02973/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02973/Kotlin/s229106115.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s229106115", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val aa = IntArray(n) { readLine()!!.toInt() }\n val palette = mutableListOf()\n var color = 0\n palette.add(aa[0])\n repeat(n - 1) {\n val a1 = aa[it]\n val a2 = aa[it + 1]\n if (a1 < a2) {\n palette[color] = a2\n return@repeat\n }\n palette.forEachIndexed { i, c ->\n if (i == color) return@forEachIndexed\n if (c < a2) {\n color = i\n palette[color] = a2\n return@repeat\n }\n }\n palette.add(a2)\n color = palette.size - 1\n }\n println(palette.size)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "sample_input": "5\n2\n1\n4\n5\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02973", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 682, "cpu_time_ms": 2111, "memory_kb": 39400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s548618491", "group_id": "codeNet:p02975", "input_text": "fun main(args: Array) {\n val n = readInputLine().toInt()\n val aList = readInputLine().split(\" \").map { it.toInt() }.toList()\n val aSet = aList.toSet()\n \n if (n % 3 != 0) {\n println(\"No\")\n return\n }\n\n if (aSet.size > 3) {\n println(\"No\")\n return\n }\n \n if (aSet.size == 3) {\n var calcedXor = 0\n for (i in aSet) {\n if (aList.count {it == i} != n / 3) {\n println(\"No\")\n return\n }\n calcedXor = calcedXor xor i \n }\n if (calcedXor != 0) {\n println(\"No\")\n return\n }\n }\n \n if (aSet.size == 2) {\n if (!aSet.contains(0)) {\n println(\"No\")\n return\n }\n \n for (i in aSet) {\n if (i == 0) {\n continue\n }\n if (aList.count {it == i} != n * 2 / 3) {\n println(\"No\")\n return\n }\n }\n }\n \n if (aSet.size == 1) {\n if (!aSet.contains(0)) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1563716513, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02975.html", "problem_id": "p02975", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02975/input.txt", "sample_output_relpath": "derived/input_output/data/p02975/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02975/Kotlin/s548618491.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s548618491", "user_id": "u505558493"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInputLine().toInt()\n val aList = readInputLine().split(\" \").map { it.toInt() }.toList()\n val aSet = aList.toSet()\n \n if (n % 3 != 0) {\n println(\"No\")\n return\n }\n\n if (aSet.size > 3) {\n println(\"No\")\n return\n }\n \n if (aSet.size == 3) {\n var calcedXor = 0\n for (i in aSet) {\n if (aList.count {it == i} != n / 3) {\n println(\"No\")\n return\n }\n calcedXor = calcedXor xor i \n }\n if (calcedXor != 0) {\n println(\"No\")\n return\n }\n }\n \n if (aSet.size == 2) {\n if (!aSet.contains(0)) {\n println(\"No\")\n return\n }\n \n for (i in aSet) {\n if (i == 0) {\n continue\n }\n if (aList.count {it == i} != n * 2 / 3) {\n println(\"No\")\n return\n }\n }\n }\n \n if (aSet.size == 1) {\n if (!aSet.contains(0)) {\n println(\"No\")\n return\n }\n }\n\n println(\"Yes\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02975", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1209, "cpu_time_ms": 547, "memory_kb": 53760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s465162768", "group_id": "codeNet:p02981", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n println(Math.min(sc.nextInt()*sc.nextInt(), sc.nextInt()))\n}", "language": "Kotlin", "metadata": {"date": 1582917500, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s465162768.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465162768", "user_id": "u733811860"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n println(Math.min(sc.nextInt()*sc.nextInt(), sc.nextInt()))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 189, "memory_kb": 31272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s490114753", "group_id": "codeNet:p02981", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val (n, a, b) = (0 until 3).map { sc.nextInt() }\n println(answer133a(n, a, b))\n}\n\nfun answer133a(n: Int, a: Int, b: Int): Int {\n return Math.min(n * a, b)\n}", "language": "Kotlin", "metadata": {"date": 1582910170, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s490114753.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s490114753", "user_id": "u369142620"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val (n, a, b) = (0 until 3).map { sc.nextInt() }\n println(answer133a(n, a, b))\n}\n\nfun answer133a(n: Int, a: Int, b: Int): Int {\n return Math.min(n * a, b)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 209, "memory_kb": 31396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s749353864", "group_id": "codeNet:p02981", "input_text": "fun main(argc:Array){\n val (N,A,B) = readLine()!!.split(\" \").map{it.toInt()}\n val ANS = if((N*A) < B) N*A else B\n println(ANS)\n}", "language": "Kotlin", "metadata": {"date": 1562550519, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Kotlin/s749353864.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749353864", "user_id": "u366696580"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(argc:Array){\n val (N,A,B) = readLine()!!.split(\" \").map{it.toInt()}\n val ANS = if((N*A) < B) N*A else B\n println(ANS)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 139, "cpu_time_ms": 242, "memory_kb": 36004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s074675967", "group_id": "codeNet:p02982", "input_text": "fun main(args: Array) = println(run {\n val (n, d) = readLine()!!.split(\" \").map { it.toInt() }\n val x = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n\n val dist = Array(n) { DoubleArray(n) }\n for (i in 0..n - 1) {\n for (j in 0..n - 1) {\n dist[i][j] = Math.sqrt(x[i].mapIndexed { k, v -> (v-x[j][k])*(v-x[j][k]) }.sum().toDouble())\n }\n }\n\n (0..n-1).sumBy { i ->\n (i+1..n-1).count { j -> dist[i][j] == Math.floor(dist[i][j]) }\n }\n\n})", "language": "Kotlin", "metadata": {"date": 1588620055, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Kotlin/s074675967.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074675967", "user_id": "u563556491"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) = println(run {\n val (n, d) = readLine()!!.split(\" \").map { it.toInt() }\n val x = (1..n).map { readLine()!!.split(\" \").map { it.toInt() } }\n\n val dist = Array(n) { DoubleArray(n) }\n for (i in 0..n - 1) {\n for (j in 0..n - 1) {\n dist[i][j] = Math.sqrt(x[i].mapIndexed { k, v -> (v-x[j][k])*(v-x[j][k]) }.sum().toDouble())\n }\n }\n\n (0..n-1).sumBy { i ->\n (i+1..n-1).count { j -> dist[i][j] == Math.floor(dist[i][j]) }\n }\n\n})", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 504, "cpu_time_ms": 239, "memory_kb": 37832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s035889141", "group_id": "codeNet:p02982", "input_text": "fun main(args: Array) {\n // Your code here!\n var (n,d) = readLine()!!.split(\" \").map{it.toInt()}\n var list:List> = (1..n).map{readLine()!!.split(\" \").map{it.toInt()}}\n var list2:MutableList = mutableListOf() \n var cnt = 0\n \n for(i in 0..n-1){\n for(k in i+1..n-1){\n var preans = 0\n for(j in 0..d-1){\n preans += (list[i][j] - list[k][j]) * (list[i][j] - list[k][j])\n }\n list2.add(Math.sqrt(preans.toDouble()))\n }\n }\n \n for(l in 0..list2.size-1){\n var intNum:Int = list2[l].toInt()\n var doubleNum:Double = list2[l] - intNum.toDouble()\n \n if(doubleNum == 0.0){\n cnt += 1\n }\n }\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1588195579, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Kotlin/s035889141.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035889141", "user_id": "u808976884"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n // Your code here!\n var (n,d) = readLine()!!.split(\" \").map{it.toInt()}\n var list:List> = (1..n).map{readLine()!!.split(\" \").map{it.toInt()}}\n var list2:MutableList = mutableListOf() \n var cnt = 0\n \n for(i in 0..n-1){\n for(k in i+1..n-1){\n var preans = 0\n for(j in 0..d-1){\n preans += (list[i][j] - list[k][j]) * (list[i][j] - list[k][j])\n }\n list2.add(Math.sqrt(preans.toDouble()))\n }\n }\n \n for(l in 0..list2.size-1){\n var intNum:Int = list2[l].toInt()\n var doubleNum:Double = list2[l] - intNum.toDouble()\n \n if(doubleNum == 0.0){\n cnt += 1\n }\n }\n println(cnt)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 770, "cpu_time_ms": 242, "memory_kb": 37900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s341772780", "group_id": "codeNet:p02986", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nclass LCA(val N: Int) {\n private val to = Array(N){ArrayList()}\n private val co = Array(N){ArrayList()}\n private val dep = IntArray(N){0}\n private val costs = LongArray(N){0}\n private var l = 0\n private val par = Array(N+1){ArrayList()}\n private var root = 0\n init {\n while ((1 shl l) < N) {\n l++\n }\n par.forEach { it.addAll(List(this.l){0}) }\n }\n fun addEdge(s: Int, t: Int, cost: Long=1L) {\n to[s].add(t)\n co[s].add(cost)\n to[t].add(s)\n co[t].add(cost)\n }\n private fun dfs(x: Int, d: Int=0, cost: Long=0L, p: Int=-1) {\n if (p != -1) {\n this.par[x][0] = p\n }\n this.dep[x] = d\n this.costs[x] = cost\n for (i in 0 until to[x].size) {\n val u = this.to[x][i]\n if (u == p)\n continue\n else\n dfs(u, d+1, cost+this.co[x][i], x)\n }\n }\n fun biuld(root: Int = 0) {\n this.root = root\n dfs(root)\n for (i in 0 until this.l - 1) {\n for (x in 0 until N) {\n this.par[x][i+1] = par[par[x][i]][i]\n }\n }\n }\n fun lca(a: Int, b: Int): Int {\n var a = a; var b = b\n if (dep[a] > dep[b]) {\n a = b.also{b = a}\n }\n var gap = dep[b] - dep[a]\n for (i in this.l - 1 downTo 0) {\n val len = 1 shl i\n if (gap >= len) {\n gap -= len\n b = par[b][i]\n }\n }\n if (a == b) {\n return a\n }\n for (i in this.l-1 downTo 0) {\n val na = par[a][i]\n val nb = par[b][i]\n if (na != nb) {\n a = na; b = nb\n }\n }\n return par[a][0]\n }\n fun length(a: Int, b: Int): Int {\n val c = lca(a, b)\n return dep[a] + dep[b] - dep[c] * 2\n }\n fun distance(a: Int, b: Int, common: Int=-1): Long {\n val c = if (common<0) this.lca(a, b) else common\n return costs[a] + costs[b] - costs[c] * 2\n }\n}\n\n\nfun main() {\n val (N,Q) = rd.readIntArray()\n val gr = LCA(N)\n val egs = Array(N){ArrayList()}\n for (i in 0 until N-1) {\n var (a, b, col, dst) = rd.readIntArray()\n a--;b--\n egs[a].add(To(b, dst.toLong(), col))\n egs[b].add(To(a, dst.toLong(), col))\n gr.addEdge(a, b, dst.toLong())\n }\n gr.biuld()\n\n data class Query(val cx: Int, val qid: Int, val coeff: Int, val dy: Long)\n val ans = LongArray(Q){0}\n val qrys = Array(N){ArrayList()}\n for (q in 0 until Q) {\n var (cx, dy, a, b) = rd.readIntArray()\n a--; b--\n\n val lca = gr.lca(a, b)\n ans[q] = gr.distance(a, b, lca)\n\n qrys[a].add(Query(cx, q, 1, dy.toLong()))\n qrys[b].add(Query(cx, q, 1, dy.toLong()))\n qrys[lca].add(Query(cx, q, -2, dy.toLong()))\n }\n\n val cnt = IntArray(N){0}\n val sum = LongArray(N){0L}\n\n fun dfs(v: Int, p: Int=-1) {\n for (qr in qrys[v]) {\n val (col,qid, coeff, dist) = qr\n var x = -sum[col]\n x += dist * cnt[col]\n ans[qid] += x * coeff\n }\n\n for (eg in egs[v]) {\n val (to, cost, col) = eg\n if (to == p) continue\n\n cnt[col] += 1\n sum[col] += cost\n dfs(to, v)\n cnt[col] -= 1\n sum[col] -= cost\n }\n }\n\n dfs(0)\n for (q in 0 until Q) {\n println(ans[q])\n }\n}\n\n\n//val rd = debug.Reader(\"abc\", \"171\", \"f\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long, val col: Int)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "language": "Kotlin", "metadata": {"date": 1593638576, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p02986.html", "problem_id": "p02986", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02986/input.txt", "sample_output_relpath": "derived/input_output/data/p02986/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02986/Kotlin/s341772780.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s341772780", "user_id": "u404244809"}, "prompt_components": {"gold_output": "130\n200\n60\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.Math.*\n\n\nclass LCA(val N: Int) {\n private val to = Array(N){ArrayList()}\n private val co = Array(N){ArrayList()}\n private val dep = IntArray(N){0}\n private val costs = LongArray(N){0}\n private var l = 0\n private val par = Array(N+1){ArrayList()}\n private var root = 0\n init {\n while ((1 shl l) < N) {\n l++\n }\n par.forEach { it.addAll(List(this.l){0}) }\n }\n fun addEdge(s: Int, t: Int, cost: Long=1L) {\n to[s].add(t)\n co[s].add(cost)\n to[t].add(s)\n co[t].add(cost)\n }\n private fun dfs(x: Int, d: Int=0, cost: Long=0L, p: Int=-1) {\n if (p != -1) {\n this.par[x][0] = p\n }\n this.dep[x] = d\n this.costs[x] = cost\n for (i in 0 until to[x].size) {\n val u = this.to[x][i]\n if (u == p)\n continue\n else\n dfs(u, d+1, cost+this.co[x][i], x)\n }\n }\n fun biuld(root: Int = 0) {\n this.root = root\n dfs(root)\n for (i in 0 until this.l - 1) {\n for (x in 0 until N) {\n this.par[x][i+1] = par[par[x][i]][i]\n }\n }\n }\n fun lca(a: Int, b: Int): Int {\n var a = a; var b = b\n if (dep[a] > dep[b]) {\n a = b.also{b = a}\n }\n var gap = dep[b] - dep[a]\n for (i in this.l - 1 downTo 0) {\n val len = 1 shl i\n if (gap >= len) {\n gap -= len\n b = par[b][i]\n }\n }\n if (a == b) {\n return a\n }\n for (i in this.l-1 downTo 0) {\n val na = par[a][i]\n val nb = par[b][i]\n if (na != nb) {\n a = na; b = nb\n }\n }\n return par[a][0]\n }\n fun length(a: Int, b: Int): Int {\n val c = lca(a, b)\n return dep[a] + dep[b] - dep[c] * 2\n }\n fun distance(a: Int, b: Int, common: Int=-1): Long {\n val c = if (common<0) this.lca(a, b) else common\n return costs[a] + costs[b] - costs[c] * 2\n }\n}\n\n\nfun main() {\n val (N,Q) = rd.readIntArray()\n val gr = LCA(N)\n val egs = Array(N){ArrayList()}\n for (i in 0 until N-1) {\n var (a, b, col, dst) = rd.readIntArray()\n a--;b--\n egs[a].add(To(b, dst.toLong(), col))\n egs[b].add(To(a, dst.toLong(), col))\n gr.addEdge(a, b, dst.toLong())\n }\n gr.biuld()\n\n data class Query(val cx: Int, val qid: Int, val coeff: Int, val dy: Long)\n val ans = LongArray(Q){0}\n val qrys = Array(N){ArrayList()}\n for (q in 0 until Q) {\n var (cx, dy, a, b) = rd.readIntArray()\n a--; b--\n\n val lca = gr.lca(a, b)\n ans[q] = gr.distance(a, b, lca)\n\n qrys[a].add(Query(cx, q, 1, dy.toLong()))\n qrys[b].add(Query(cx, q, 1, dy.toLong()))\n qrys[lca].add(Query(cx, q, -2, dy.toLong()))\n }\n\n val cnt = IntArray(N){0}\n val sum = LongArray(N){0L}\n\n fun dfs(v: Int, p: Int=-1) {\n for (qr in qrys[v]) {\n val (col,qid, coeff, dist) = qr\n var x = -sum[col]\n x += dist * cnt[col]\n ans[qid] += x * coeff\n }\n\n for (eg in egs[v]) {\n val (to, cost, col) = eg\n if (to == p) continue\n\n cnt[col] += 1\n sum[col] += cost\n dfs(to, v)\n cnt[col] -= 1\n sum[col] -= cost\n }\n }\n\n dfs(0)\n for (q in 0 until Q) {\n println(ans[q])\n }\n}\n\n\n//val rd = debug.Reader(\"abc\", \"171\", \"f\", \"sample-1\")\nval rd = Reader()\nfun main(args: Array) {\n Thread(null, MainThread(), \"mainThread\", 128 * 1024 * 1024).start()\n}\n\n\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int)\ndata class To(val idx: Int, val cost: Long, val col: Int)\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nclass MainThread : Runnable {\n override fun run() { main() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.\nHere the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.\n\nAnswer the following Q queries:\n\nQuery j (1 \\leq j \\leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\n1 \\leq c_i \\leq N-1\n\n1 \\leq d_i \\leq 10^4\n\n1 \\leq x_j \\leq N-1\n\n1 \\leq y_j \\leq 10^4\n\n1 \\leq u_j < v_j \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\na_1 b_1 c_1 d_1\n:\na_{N-1} b_{N-1} c_{N-1} d_{N-1}\nx_1 y_1 u_1 v_1\n:\nx_Q y_Q u_Q v_Q\n\nOutput\n\nPrint Q lines. The j-th line (1 \\leq j \\leq Q) should contain the answer to Query j.\n\nSample Input 1\n\n5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n\nSample Output 1\n\n130\n200\n60\n\nThe graph in this input is as follows:\n\nHere the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.\n\nQuery 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.\n\nQuery 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.\n\nQuery 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.", "sample_input": "5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n"}, "reference_outputs": ["130\n200\n60\n"], "source_document_id": "p02986", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.\nHere the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.\n\nAnswer the following Q queries:\n\nQuery j (1 \\leq j \\leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\n1 \\leq c_i \\leq N-1\n\n1 \\leq d_i \\leq 10^4\n\n1 \\leq x_j \\leq N-1\n\n1 \\leq y_j \\leq 10^4\n\n1 \\leq u_j < v_j \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\na_1 b_1 c_1 d_1\n:\na_{N-1} b_{N-1} c_{N-1} d_{N-1}\nx_1 y_1 u_1 v_1\n:\nx_Q y_Q u_Q v_Q\n\nOutput\n\nPrint Q lines. The j-th line (1 \\leq j \\leq Q) should contain the answer to Query j.\n\nSample Input 1\n\n5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n\nSample Output 1\n\n130\n200\n60\n\nThe graph in this input is as follows:\n\nHere the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.\n\nQuery 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.\n\nQuery 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.\n\nQuery 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4906, "cpu_time_ms": 2370, "memory_kb": 171680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s714361108", "group_id": "codeNet:p02987", "input_text": "fun main(arr:Array) {\nval s = readLine()!!\nprintln(if(s.toSet().all {a-> s.count { it == a } == 2 }) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1583805079, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Kotlin/s714361108.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714361108", "user_id": "u269969976"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(arr:Array) {\nval s = readLine()!!\nprintln(if(s.toSet().all {a-> s.count { it == a } == 2 }) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 128, "cpu_time_ms": 207, "memory_kb": 31800}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s930491704", "group_id": "codeNet:p02987", "input_text": "\n\nfun main(args: Array) {\n val S = readLine()!!\n val result = S.all { c -> S.count { it == c } == 2 }\n println(if (result) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1562559140, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Kotlin/s930491704.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930491704", "user_id": "u979004569"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\n\nfun main(args: Array) {\n val S = readLine()!!\n val result = S.all { c -> S.count { it == c } == 2 }\n println(if (result) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 153, "cpu_time_ms": 215, "memory_kb": 33564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s805851710", "group_id": "codeNet:p02987", "input_text": "fun main(args: Array) {\n val l = readLine()!!.toCharArray().sorted()\n (if(l[0] == l[1] && l[2] == l[3] && l[0] != l[3]) \"Yes\" else \"No\").let{ println(it)}\n}", "language": "Kotlin", "metadata": {"date": 1561857025, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Kotlin/s805851710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s805851710", "user_id": "u227189389"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val l = readLine()!!.toCharArray().sorted()\n (if(l[0] == l[1] && l[2] == l[3] && l[0] != l[3]) \"Yes\" else \"No\").let{ println(it)}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 170, "cpu_time_ms": 226, "memory_kb": 34112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s678293604", "group_id": "codeNet:p02987", "input_text": "fun CharSequence.groupingCount(): Map {\n val map = mutableMapOf()\n for (element in this) {\n map[element] = map.getOrElse(element) { 0 } + 1\n }\n return map\n}\n\nfun main(args: Array) {\n val s = readLine()!!.groupingCount()\n println(if (s.size == 2 && s.values.all { it == 2 }) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1561856744, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Kotlin/s678293604.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678293604", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun CharSequence.groupingCount(): Map {\n val map = mutableMapOf()\n for (element in this) {\n map[element] = map.getOrElse(element) { 0 } + 1\n }\n return map\n}\n\nfun main(args: Array) {\n val s = readLine()!!.groupingCount()\n println(if (s.size == 2 && s.values.all { it == 2 }) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 216, "memory_kb": 33772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s913665009", "group_id": "codeNet:p02989", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val d = Array(n) { sc.nextInt() }.sorted()\n\n println(d[n/2] - d[n/2-1])\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1583753586, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Kotlin/s913665009.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s913665009", "user_id": "u194412908"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val d = Array(n) { sc.nextInt() }.sorted()\n\n println(d[n/2] - d[n/2-1])\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2878, "cpu_time_ms": 569, "memory_kb": 38772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s470592470", "group_id": "codeNet:p02990", "input_text": "fun main(args: Array) {\n val mod = 1e9.toLong() + 7\n\n class Comb {\n\n val n = 2000\n\n val fact = LongArray(n + 1)\n val factInv = LongArray(n + 1)\n\n init {\n fact[1] = 1L\n for (i in 2 .. n) {\n fact[i] = fact[i - 1] * i % mod\n }\n factInv[n] = inv(fact[n])\n for (i in n downTo 1) {\n factInv[i - 1] = factInv[i] * i % mod\n }\n }\n\n fun pow(base: Long, exp: Long): Long {\n if (exp == 0L) return 1L\n var a = pow(base, exp shr 1)\n a *= a\n a %= mod\n if (exp and 1L == 0L) return a\n return base * a % mod\n }\n\n private fun inv(x: Long): Long {\n return pow(x, mod - 2)\n }\n\n fun comb(n: Int, k: Int): Long {\n if (k !in 0..n) return 0L\n return fact[n] * factInv[k] % mod * factInv[n - k] % mod\n }\n\n }\n\n val cb = Comb()\n\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n\n for (i in 1..k) {\n val a = cb.comb(n - k + 1, i)\n val b = cb.pow(i.toLong(), k - i.toLong())\n println(a * b % mod)\n }\n\n}\n", "language": "Kotlin", "metadata": {"date": 1579901553, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Kotlin/s470592470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s470592470", "user_id": "u863309603"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "fun main(args: Array) {\n val mod = 1e9.toLong() + 7\n\n class Comb {\n\n val n = 2000\n\n val fact = LongArray(n + 1)\n val factInv = LongArray(n + 1)\n\n init {\n fact[1] = 1L\n for (i in 2 .. n) {\n fact[i] = fact[i - 1] * i % mod\n }\n factInv[n] = inv(fact[n])\n for (i in n downTo 1) {\n factInv[i - 1] = factInv[i] * i % mod\n }\n }\n\n fun pow(base: Long, exp: Long): Long {\n if (exp == 0L) return 1L\n var a = pow(base, exp shr 1)\n a *= a\n a %= mod\n if (exp and 1L == 0L) return a\n return base * a % mod\n }\n\n private fun inv(x: Long): Long {\n return pow(x, mod - 2)\n }\n\n fun comb(n: Int, k: Int): Long {\n if (k !in 0..n) return 0L\n return fact[n] * factInv[k] % mod * factInv[n - k] % mod\n }\n\n }\n\n val cb = Comb()\n\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n\n for (i in 1..k) {\n val a = cb.comb(n - k + 1, i)\n val b = cb.pow(i.toLong(), k - i.toLong())\n println(a * b % mod)\n }\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1204, "cpu_time_ms": 290, "memory_kb": 38464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s256681231", "group_id": "codeNet:p02990", "input_text": "fun main(args: Array)\n{\n val (n, k) = readNInts()\n\n val mod = 1000000007L\n val c = Array(2001, { LongArray(2001) })\n for (i in 0..2000) {\n for (r in 0..i) {\n if (r == 0 || r == i) {\n c[i][r] = 1L\n continue\n }\n\n c[i][r] = c[i-1][r-1] + c[i-1][r]\n }\n }\n\n for (i in 1..k) {\n val a = c[n-k+1][i] % mod\n val b = c[k-1][i-1] % mod\n\n val ans: Long = (a * b) % mod\n println(ans)\n }\n}\n\n\n// Read an integer\n// Usage: val a = readInt()\nprivate fun readInt() = readLine()!!.toInt()\n\n// Read N integers separated by \" \"\n// Usage: val (a, b, c) = readNInts()\nprivate fun readNInts() = readLine()!!.split(\" \").map(String::toInt)\n\n// Read a string\n// Usage: val a = readString()\nprivate fun readString() = readLine()!!\n", "language": "Kotlin", "metadata": {"date": 1566280585, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Kotlin/s256681231.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s256681231", "user_id": "u118477733"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "fun main(args: Array)\n{\n val (n, k) = readNInts()\n\n val mod = 1000000007L\n val c = Array(2001, { LongArray(2001) })\n for (i in 0..2000) {\n for (r in 0..i) {\n if (r == 0 || r == i) {\n c[i][r] = 1L\n continue\n }\n\n c[i][r] = c[i-1][r-1] + c[i-1][r]\n }\n }\n\n for (i in 1..k) {\n val a = c[n-k+1][i] % mod\n val b = c[k-1][i-1] % mod\n\n val ans: Long = (a * b) % mod\n println(ans)\n }\n}\n\n\n// Read an integer\n// Usage: val a = readInt()\nprivate fun readInt() = readLine()!!.toInt()\n\n// Read N integers separated by \" \"\n// Usage: val (a, b, c) = readNInts()\nprivate fun readNInts() = readLine()!!.split(\" \").map(String::toInt)\n\n// Read a string\n// Usage: val a = readString()\nprivate fun readString() = readLine()!!\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 848, "cpu_time_ms": 338, "memory_kb": 88068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285287429", "group_id": "codeNet:p02990", "input_text": "package ABContest_132\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n\n val modVal = 1e9.toLong() + 7\n\n initTable(modVal)\n\n for ( i in 1 .. k) {\n val insertPlaceNum = combinationModWithTable((n-k+1).toLong(), i.toLong(), modVal)\n\n val divGroupNum = combinationModWithTable((k-1).toLong(), (i-1).toLong(), modVal)\n\n println(insertPlaceNum * divGroupNum % modVal)\n }\n\n}\n\n\n/**\n * プロコンで頻出の mod 計算を定義したクラス\n *\n * 参考 : https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a\n */\n\n// 階乗の mod 並びに 逆元の mod を格納するための配列を初期化\nprivate const val MAX = 1e4.toInt() // MAX は求める必要がある階乗の部分の計算に対してのみ求める (10^7 とすると RuntimeError になったので注意 メモリが足りなくなっている? )\nprivate val fact = LongArray(MAX + 1) { -1 } // n 番目は n! の mod\nprivate val finv = LongArray(MAX + 1) { -1 } // n 番目は n! の逆元\nprivate val inv = LongArray(MAX + 1) { -1 } // n 番目は n の逆元\n\n\n/**\n * 階乗のmod 並びに 逆元 テーブルを初期化\n * それぞれの計算には漸化式を用いており,各逆元の計算は O(1) で行われる.フェルマーの小定理も,拡張Euclid の互除法も必要ない OMG\n * mod値が 1e9+7 だと,途中計算で mod を求める前に Long最大値 を超えるので LongArray を使用\n *\n * テーブル全体(N)ではなく,単体で逆元計算を行うときには上記定理を用いた計算を実行すると O(N) -> O(log modVal) に計算量を削減できる\n *\n * <注意>\n * nCk mod p の計算に用いる際の暗黙の前提 : p > n かつ k! (k<=n) のどれとも p が一致しない -> 「p が n より大きい素数」 だと条件が満たされやすい\n * 例えば modVal 以上の 階乗のmod値は 0 になるので注意 5C2 mod 3 とかを計算しようとすると分子の階乗部分が 0 になって正しく計算できないので注意\n * 正しくは (5*4 / 2*1) mod 3 = 1 だが,この方式だと (5*4*3*2*1 / 2*1*3*2*1) mod 3 = 0 となってしまう\n */\nfun initTable(modVal: Long) {\n\n //初期値設定\n fact[0] = 1\n fact[1] = 1\n inv[0] = 1 //?\n inv[1] = 1\n finv[0] = 1\n finv[1] = 1\n\n for (i in 2..MAX) {\n\n // 階乗の mod については普通に掛け算 & mod 計算でOK\n fact[i] = fact[i - 1] * i % modVal\n\n // 各 i に対する逆元を求めて格納しておく (finv 確認 or 直接計算 )\n\n // 実装上の工夫\n // 1.modVal を足しているのは inv[i] を常に正の値にするため ( inv[i] は常に modVal を前提とした計算で用いるので modVal が加えられていても影響は無い)\n // 2. 新たな inv[i] を求める時に % modVal をしているのは 値のオーバーフローを避けるため & inv[i] は常にm modVal を前提とした計算で 掛け算に用いられるため どの段階で %modVal をとっても影響は無い\n\n inv[i] = modVal - inv[(modVal % i).toInt()] * (modVal / i) % modVal\n\n // inv[i] の結果を finv[i-1] に掛け合わせて mod を取った結果が finv[i] ( 逆元の累乗 ) 累乗の逆元 = 逆元の総積\n finv[i] = finv[i - 1] * inv[i] % modVal\n }\n}\n\n\n/**\n * 事前に計算した逆元テーブルから nCk mod modVal を計算\n */\nfun combinationModWithTable(n: Long, k: Long, modVal: Long): Long {\n val numeTerm = fact[n.toInt()]\n val denomTerm = finv[k.toInt()] * finv[(n - k).toInt()] % modVal\n\n return (numeTerm * denomTerm) % modVal\n}\n\n\nprivate fun factMod(n: Long, modVal: Long): Long {\n var ans = 1L\n for (i in 1..n) {\n ans = (ans * i) % modVal\n }\n\n return ans\n}\n\n\nfun plusMod(a: Long, b: Long, modVal: Long): Long {\n return (a + b) % modVal\n}\n\nfun minusMod(a: Long, b: Long, modVal: Long): Long{\n return (a - b + modVal) % modVal\n}\n\nfun timesMod(inputs: List, modVal: Long): Long {\n return inputs.reduce { acc, i -> (acc % modVal) * (i % modVal) % modVal }\n}\n\n/**\n * mod の世界での割り算を実装\n *\n * a/b mod p を求めたい場合 mod p における b の逆元(b^-1)を求めて (a * b^-1) mod p とする\n */\n\nfun divMod(numerator: Long, denominator: Long, modVal: Long): Long {\n\n // 拡張Euclidの互除法を用いた 逆元計算の実装では 負の 値が返ってくることもあるので ( + modVal) % modVal をする\n val invMod = (invModEuclid(denominator, modVal).first + modVal) % modVal\n\n return (numerator * invMod) % modVal\n}\n\n/**\n * mod modVal の世界での逆元を求める O(log modVal)\n *\n * 定義 a * b mod modVal = 1 となるとき b を mod modVal の世界での逆元と呼ぶ\n *\n * -> x / a mod modVal = x * b mod modVal と書き換える事ができる\n * -> mod の掛け算は逐次計算できるので OverFlow を避けられる (嬉しい)\n *\n * フェルマーの小定理を元にした実装, modVal は素数である必要がある\n */\nfun invModFermat(a: Long, modVal: Long): Long {\n return powMod(a, modVal - 2, modVal)\n}\n\n\n/**\n * mod b の世界での a の逆元を求める\n * ユークリッドの互除法に類似した計算を行うので 最悪 O(log modVal) (ユークリッドの互除法の計算量は log modVal 以下になる)\n * -> 平均的には フェルマーの小定理を用いた逆元計算よりも計算量が少なくなる (あちらは 累乗計算で 必ず log(modVal-2) 必要\n *\n * a と modVal は互いに素 である必要がある\n * <-> a , modVal が互いに素 でないとしたら?\n *\n * ax + by = c を満たす整数 x, y が存在する必要十分条件は c = k gcd(a,b) を満たす k が存在すること (そうでなければ整数解は存在しない)\n *\n * ->\n *\n * ax + by = gcd(a,b) を満たす x, y は存在する\n *\n * ->\n *\n * a, b が互いに素 であれば\n *\n * ax + by = 1 を満たす x, y は存在する といえる\n *\n * ->\n *\n * つまり逆元が存在する -> ユークリッドの互除法で解を求める\n *\n * ※ 「mod p において a の逆元が存在する」 と 「ax + py = 1 となる 整数解 x,y が存在する」 は等価なので\n * 「mod p において a の逆元が存在する」 ための必要十分条件は 「p と a が互いに素」\n *\n * 丁寧に再帰計算で実装する,, アドレスを渡して,グローバル変数のようにみなして計算するのは賢すぎるので変数で渡していくことを考える\n * -> 2つの値を受け取って2つの値を返す実装に\n *\n * なお,最終的に用いる値は 返された値の第一要素なので注意 (使いづらい?)また,負の値が返ってくるかもしれないことには注意\n */\nfun invModEuclid(a: Long, b: Long): Pair {\n\n // 互除法同様, 渡されたあまりが 0 になったら再帰を終了する\n if (b == 0L) {\n return Pair(1, 0)\n }\n\n // 1つ下の b, a%b に対する計算結果から a, b についての結果を計算する\n val (s, t) = invModEuclid(b, a % b)\n\n return Pair(t, s - a / b * t)\n}\n\n/**\n * a^n mod modVal を計算する\n * 二分累乗法で累乗計算を O(logN) で行いつつ,OverFlow を避けるため適宜 mod 計算を行う\n */\nfun powMod(a: Long, n: Long, modVal: Long, ans: Long = 1): Long {\n\n if (n == 0L) {\n return ans\n }\n\n // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ\n if (n.and(1L) == 0L) {\n return powMod(a * a % modVal, n.shr(1), modVal, ans)\n }\n\n // ビット演算の結果 2^9 の毛型 1 の場合は ans を更新\n return powMod(a * a % modVal, n.shr(1), modVal, ans * a % modVal)\n}\n", "language": "Kotlin", "metadata": {"date": 1561859148, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Kotlin/s285287429.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s285287429", "user_id": "u889750959"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "package ABContest_132\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n\n val modVal = 1e9.toLong() + 7\n\n initTable(modVal)\n\n for ( i in 1 .. k) {\n val insertPlaceNum = combinationModWithTable((n-k+1).toLong(), i.toLong(), modVal)\n\n val divGroupNum = combinationModWithTable((k-1).toLong(), (i-1).toLong(), modVal)\n\n println(insertPlaceNum * divGroupNum % modVal)\n }\n\n}\n\n\n/**\n * プロコンで頻出の mod 計算を定義したクラス\n *\n * 参考 : https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a\n */\n\n// 階乗の mod 並びに 逆元の mod を格納するための配列を初期化\nprivate const val MAX = 1e4.toInt() // MAX は求める必要がある階乗の部分の計算に対してのみ求める (10^7 とすると RuntimeError になったので注意 メモリが足りなくなっている? )\nprivate val fact = LongArray(MAX + 1) { -1 } // n 番目は n! の mod\nprivate val finv = LongArray(MAX + 1) { -1 } // n 番目は n! の逆元\nprivate val inv = LongArray(MAX + 1) { -1 } // n 番目は n の逆元\n\n\n/**\n * 階乗のmod 並びに 逆元 テーブルを初期化\n * それぞれの計算には漸化式を用いており,各逆元の計算は O(1) で行われる.フェルマーの小定理も,拡張Euclid の互除法も必要ない OMG\n * mod値が 1e9+7 だと,途中計算で mod を求める前に Long最大値 を超えるので LongArray を使用\n *\n * テーブル全体(N)ではなく,単体で逆元計算を行うときには上記定理を用いた計算を実行すると O(N) -> O(log modVal) に計算量を削減できる\n *\n * <注意>\n * nCk mod p の計算に用いる際の暗黙の前提 : p > n かつ k! (k<=n) のどれとも p が一致しない -> 「p が n より大きい素数」 だと条件が満たされやすい\n * 例えば modVal 以上の 階乗のmod値は 0 になるので注意 5C2 mod 3 とかを計算しようとすると分子の階乗部分が 0 になって正しく計算できないので注意\n * 正しくは (5*4 / 2*1) mod 3 = 1 だが,この方式だと (5*4*3*2*1 / 2*1*3*2*1) mod 3 = 0 となってしまう\n */\nfun initTable(modVal: Long) {\n\n //初期値設定\n fact[0] = 1\n fact[1] = 1\n inv[0] = 1 //?\n inv[1] = 1\n finv[0] = 1\n finv[1] = 1\n\n for (i in 2..MAX) {\n\n // 階乗の mod については普通に掛け算 & mod 計算でOK\n fact[i] = fact[i - 1] * i % modVal\n\n // 各 i に対する逆元を求めて格納しておく (finv 確認 or 直接計算 )\n\n // 実装上の工夫\n // 1.modVal を足しているのは inv[i] を常に正の値にするため ( inv[i] は常に modVal を前提とした計算で用いるので modVal が加えられていても影響は無い)\n // 2. 新たな inv[i] を求める時に % modVal をしているのは 値のオーバーフローを避けるため & inv[i] は常にm modVal を前提とした計算で 掛け算に用いられるため どの段階で %modVal をとっても影響は無い\n\n inv[i] = modVal - inv[(modVal % i).toInt()] * (modVal / i) % modVal\n\n // inv[i] の結果を finv[i-1] に掛け合わせて mod を取った結果が finv[i] ( 逆元の累乗 ) 累乗の逆元 = 逆元の総積\n finv[i] = finv[i - 1] * inv[i] % modVal\n }\n}\n\n\n/**\n * 事前に計算した逆元テーブルから nCk mod modVal を計算\n */\nfun combinationModWithTable(n: Long, k: Long, modVal: Long): Long {\n val numeTerm = fact[n.toInt()]\n val denomTerm = finv[k.toInt()] * finv[(n - k).toInt()] % modVal\n\n return (numeTerm * denomTerm) % modVal\n}\n\n\nprivate fun factMod(n: Long, modVal: Long): Long {\n var ans = 1L\n for (i in 1..n) {\n ans = (ans * i) % modVal\n }\n\n return ans\n}\n\n\nfun plusMod(a: Long, b: Long, modVal: Long): Long {\n return (a + b) % modVal\n}\n\nfun minusMod(a: Long, b: Long, modVal: Long): Long{\n return (a - b + modVal) % modVal\n}\n\nfun timesMod(inputs: List, modVal: Long): Long {\n return inputs.reduce { acc, i -> (acc % modVal) * (i % modVal) % modVal }\n}\n\n/**\n * mod の世界での割り算を実装\n *\n * a/b mod p を求めたい場合 mod p における b の逆元(b^-1)を求めて (a * b^-1) mod p とする\n */\n\nfun divMod(numerator: Long, denominator: Long, modVal: Long): Long {\n\n // 拡張Euclidの互除法を用いた 逆元計算の実装では 負の 値が返ってくることもあるので ( + modVal) % modVal をする\n val invMod = (invModEuclid(denominator, modVal).first + modVal) % modVal\n\n return (numerator * invMod) % modVal\n}\n\n/**\n * mod modVal の世界での逆元を求める O(log modVal)\n *\n * 定義 a * b mod modVal = 1 となるとき b を mod modVal の世界での逆元と呼ぶ\n *\n * -> x / a mod modVal = x * b mod modVal と書き換える事ができる\n * -> mod の掛け算は逐次計算できるので OverFlow を避けられる (嬉しい)\n *\n * フェルマーの小定理を元にした実装, modVal は素数である必要がある\n */\nfun invModFermat(a: Long, modVal: Long): Long {\n return powMod(a, modVal - 2, modVal)\n}\n\n\n/**\n * mod b の世界での a の逆元を求める\n * ユークリッドの互除法に類似した計算を行うので 最悪 O(log modVal) (ユークリッドの互除法の計算量は log modVal 以下になる)\n * -> 平均的には フェルマーの小定理を用いた逆元計算よりも計算量が少なくなる (あちらは 累乗計算で 必ず log(modVal-2) 必要\n *\n * a と modVal は互いに素 である必要がある\n * <-> a , modVal が互いに素 でないとしたら?\n *\n * ax + by = c を満たす整数 x, y が存在する必要十分条件は c = k gcd(a,b) を満たす k が存在すること (そうでなければ整数解は存在しない)\n *\n * ->\n *\n * ax + by = gcd(a,b) を満たす x, y は存在する\n *\n * ->\n *\n * a, b が互いに素 であれば\n *\n * ax + by = 1 を満たす x, y は存在する といえる\n *\n * ->\n *\n * つまり逆元が存在する -> ユークリッドの互除法で解を求める\n *\n * ※ 「mod p において a の逆元が存在する」 と 「ax + py = 1 となる 整数解 x,y が存在する」 は等価なので\n * 「mod p において a の逆元が存在する」 ための必要十分条件は 「p と a が互いに素」\n *\n * 丁寧に再帰計算で実装する,, アドレスを渡して,グローバル変数のようにみなして計算するのは賢すぎるので変数で渡していくことを考える\n * -> 2つの値を受け取って2つの値を返す実装に\n *\n * なお,最終的に用いる値は 返された値の第一要素なので注意 (使いづらい?)また,負の値が返ってくるかもしれないことには注意\n */\nfun invModEuclid(a: Long, b: Long): Pair {\n\n // 互除法同様, 渡されたあまりが 0 になったら再帰を終了する\n if (b == 0L) {\n return Pair(1, 0)\n }\n\n // 1つ下の b, a%b に対する計算結果から a, b についての結果を計算する\n val (s, t) = invModEuclid(b, a % b)\n\n return Pair(t, s - a / b * t)\n}\n\n/**\n * a^n mod modVal を計算する\n * 二分累乗法で累乗計算を O(logN) で行いつつ,OverFlow を避けるため適宜 mod 計算を行う\n */\nfun powMod(a: Long, n: Long, modVal: Long, ans: Long = 1): Long {\n\n if (n == 0L) {\n return ans\n }\n\n // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ\n if (n.and(1L) == 0L) {\n return powMod(a * a % modVal, n.shr(1), modVal, ans)\n }\n\n // ビット演算の結果 2^9 の毛型 1 の場合は ans を更新\n return powMod(a * a % modVal, n.shr(1), modVal, ans * a % modVal)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7881, "cpu_time_ms": 160, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s177746897", "group_id": "codeNet:p02993", "input_text": "\n fun main(args: Array) {\n var result: String = \"Good\"\n val n = readNext()\n if(n[0] == n[1] ||\n n[1] == n[2] ||\n n[2] == n[3]) {\n result = \"Bad\"\n }\n println(result)\n }\n\n\n fun readNext(): String {\n return readLine()!!\n }", "language": "Kotlin", "metadata": {"date": 1564636118, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02993.html", "problem_id": "p02993", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02993/input.txt", "sample_output_relpath": "derived/input_output/data/p02993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02993/Kotlin/s177746897.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s177746897", "user_id": "u376174428"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": "\n fun main(args: Array) {\n var result: String = \"Good\"\n val n = readNext()\n if(n[0] == n[1] ||\n n[1] == n[2] ||\n n[2] == n[3]) {\n result = \"Bad\"\n }\n println(result)\n }\n\n\n fun readNext(): String {\n return readLine()!!\n }", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "sample_input": "3776\n"}, "reference_outputs": ["Bad\n"], "source_document_id": "p02993", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 322, "cpu_time_ms": 201, "memory_kb": 31780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s534748455", "group_id": "codeNet:p02994", "input_text": "fun main(args: Array) = yorukatsu15a()\n\nfun yorukatsu15a() {\n val (n, l) = readLine()!!.split(' ').map { it.toInt() }\n\n val answer = (l until l + n).sum() - (l until l + n).minBy { Math.abs(it) }!!\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1586912838, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Kotlin/s534748455.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s534748455", "user_id": "u139478771"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu15a()\n\nfun yorukatsu15a() {\n val (n, l) = readLine()!!.split(' ').map { it.toInt() }\n\n val answer = (l until l + n).sum() - (l until l + n).minBy { Math.abs(it) }!!\n\n println(answer)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 257, "memory_kb": 38452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s273527287", "group_id": "codeNet:p02994", "input_text": "private fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\nfun main(args: Array) {\n val (N, L) = readInts()\n println((0 until N).map { it + L }.sortedBy { Math.abs(it) }.drop(1).sum())\n}\n", "language": "Kotlin", "metadata": {"date": 1561259112, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Kotlin/s273527287.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273527287", "user_id": "u963316883"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "private fun readInts() = readLine()!!.split(\" \").map(String::toInt)\n\nfun main(args: Array) {\n val (N, L) = readInts()\n println((0 until N).map { it + L }.sortedBy { Math.abs(it) }.drop(1).sum())\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 211, "cpu_time_ms": 239, "memory_kb": 37872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s191566936", "group_id": "codeNet:p02994", "input_text": "fun abs(x: Int) = if (x < 0) -x else x\n\nfun main(args: Array) {\n val inputs = readLine()!!.split(' ').map { it.toInt() }\n val n = inputs[0]\n val l = inputs[1]\n val tastes = (0.until(n)).map { i -> l + i }\n val allapplepietaste = tastes.sum()\n val subtastes = (0.until(n)).map { i -> allapplepietaste - tastes[i] }\n val subtaste = subtastes.minBy { sub -> abs(allapplepietaste - sub) }\n println(subtaste)\n}", "language": "Kotlin", "metadata": {"date": 1561252205, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Kotlin/s191566936.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s191566936", "user_id": "u909806206"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun abs(x: Int) = if (x < 0) -x else x\n\nfun main(args: Array) {\n val inputs = readLine()!!.split(' ').map { it.toInt() }\n val n = inputs[0]\n val l = inputs[1]\n val tastes = (0.until(n)).map { i -> l + i }\n val allapplepietaste = tastes.sum()\n val subtastes = (0.until(n)).map { i -> allapplepietaste - tastes[i] }\n val subtaste = subtastes.minBy { sub -> abs(allapplepietaste - sub) }\n println(subtaste)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 437, "cpu_time_ms": 239, "memory_kb": 38296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s235497363", "group_id": "codeNet:p02995", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nfun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val A = sc.next().toLong()\n val B = sc.next().toLong()\n val C = sc.next().toLong()\n val D = sc.next().toLong()\n val E = lcm(C, D)\n val b = (B / C + B / D - B / E)\n val a = ((A - 1) / C + (A - 1) / D - (A - 1) / E)\n val ans = (B - A + 1) - (b - a)\n pw.println(ans)\n\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1591037333, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Kotlin/s235497363.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235497363", "user_id": "u297767059"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nfun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val A = sc.next().toLong()\n val B = sc.next().toLong()\n val C = sc.next().toLong()\n val D = sc.next().toLong()\n val E = lcm(C, D)\n val b = (B / C + B / D - B / E)\n val a = ((A - 1) / C + (A - 1) / D - (A - 1) / E)\n val ans = (B - A + 1) - (b - a)\n pw.println(ans)\n\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 688, "cpu_time_ms": 176, "memory_kb": 31000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s484066222", "group_id": "codeNet:p02995", "input_text": "fun main(args: Array) {\n val (A, B, C, D) = readLine()!!.split(\" \").map(String::toLong)\n val c = B / C - (A - 1) / C\n val d = B / D - (A - 1) / D\n val cd = B / lcm(C, D) - (A - 1) / lcm(C, D)\n println(B - (A - 1) - c - d + cd)\n}\n\n// 最小公倍数\nfun lcm(a: Long, b: Long): Long {\n return a / gcd(a, b) * b\n}\n\n// 最大公約数\ntailrec fun gcd(a: Long, b: Long): Long {\n if (a < b) return gcd(b, a)\n if (b == 0L) return a\n if (a <= 0L) throw IllegalArgumentException()\n return gcd(b, a % b)\n}", "language": "Kotlin", "metadata": {"date": 1590253889, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Kotlin/s484066222.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s484066222", "user_id": "u860789370"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B, C, D) = readLine()!!.split(\" \").map(String::toLong)\n val c = B / C - (A - 1) / C\n val d = B / D - (A - 1) / D\n val cd = B / lcm(C, D) - (A - 1) / lcm(C, D)\n println(B - (A - 1) - c - d + cd)\n}\n\n// 最小公倍数\nfun lcm(a: Long, b: Long): Long {\n return a / gcd(a, b) * b\n}\n\n// 最大公約数\ntailrec fun gcd(a: Long, b: Long): Long {\n if (a < b) return gcd(b, a)\n if (b == 0L) return a\n if (a <= 0L) throw IllegalArgumentException()\n return gcd(b, a % b)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 533, "cpu_time_ms": 242, "memory_kb": 38068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s658950255", "group_id": "codeNet:p02996", "input_text": "fun main(args: Array) {\n val N = nextInt()\n val AB = Array(N) { listOfInt() }.sortedBy { it[1] }\n var ans = true\n var t = 0\n repeat(N) {\n t += AB[it][0]\n if (t > AB[it][1]) ans = false\n }\n println(\"${if (ans) \"Yes\" else \"No\"}\")\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }", "language": "Kotlin", "metadata": {"date": 1581173381, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02996/input.txt", "sample_output_relpath": "derived/input_output/data/p02996/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02996/Kotlin/s658950255.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658950255", "user_id": "u043150661"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextInt()\n val AB = Array(N) { listOfInt() }.sortedBy { it[1] }\n var ans = true\n var t = 0\n repeat(N) {\n t += AB[it][0]\n if (t > AB[it][1]) ans = false\n }\n println(\"${if (ans) \"Yes\" else \"No\"}\")\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }", "problem_context": "Score: 400 points\n\nProblem Statement\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered 1 to N.\n\nIt takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.\n\nKizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.\n\nCan Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n.\n.\n.\nA_N B_N\n\nOutput\n\nIf Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.\n\nSample Input 1\n\n5\n2 4\n1 9\n1 8\n4 9\n3 12\n\nSample Output 1\n\nYes\n\nHe can complete all the jobs in time by, for example, doing them in the following order:\n\nDo Job 2 from time 0 to 1.\n\nDo Job 1 from time 1 to 3.\n\nDo Job 4 from time 3 to 7.\n\nDo Job 3 from time 7 to 8.\n\nDo Job 5 from time 8 to 11.\n\nNote that it is fine to complete Job 3 exactly at the deadline, time 8.\n\nSample Input 2\n\n3\n334 1000\n334 1000\n334 1000\n\nSample Output 2\n\nNo\n\nHe cannot complete all the jobs in time, no matter what order he does them in.\n\nSample Input 3\n\n30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334 5720\n\nSample Output 3\n\nYes", "sample_input": "5\n2 4\n1 9\n1 8\n4 9\n3 12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02996", "source_text": "Score: 400 points\n\nProblem Statement\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered 1 to N.\n\nIt takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.\n\nKizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.\n\nCan Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n.\n.\n.\nA_N B_N\n\nOutput\n\nIf Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.\n\nSample Input 1\n\n5\n2 4\n1 9\n1 8\n4 9\n3 12\n\nSample Output 1\n\nYes\n\nHe can complete all the jobs in time by, for example, doing them in the following order:\n\nDo Job 2 from time 0 to 1.\n\nDo Job 1 from time 1 to 3.\n\nDo Job 4 from time 3 to 7.\n\nDo Job 3 from time 7 to 8.\n\nDo Job 5 from time 8 to 11.\n\nNote that it is fine to complete Job 3 exactly at the deadline, time 8.\n\nSample Input 2\n\n3\n334 1000\n334 1000\n334 1000\n\nSample Output 2\n\nNo\n\nHe cannot complete all the jobs in time, no matter what order he does them in.\n\nSample Input 3\n\n30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334 5720\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 440, "cpu_time_ms": 1287, "memory_kb": 134708}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s243392366", "group_id": "codeNet:p02999", "input_text": "fun main(args: Array) {\n val str = readLine()!!.split(\" \")\n val num1 = str[0].toInt()\n var num2 = str[1].toInt()\n println(if (num1 < num2) 0 else 10)\n}\n", "language": "Kotlin", "metadata": {"date": 1561222884, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02999/input.txt", "sample_output_relpath": "derived/input_output/data/p02999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02999/Kotlin/s243392366.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s243392366", "user_id": "u520434261"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "fun main(args: Array) {\n val str = readLine()!!.split(\" \")\n val num1 = str[0].toInt()\n var num2 = str[1].toInt()\n println(if (num1 < num2) 0 else 10)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02999", "source_text": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 236, "memory_kb": 37560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s636430213", "group_id": "codeNet:p03000", "input_text": "fun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var iti = 0\n var count = 0\n for (i in 1 until n+1){\n iti += l[i-1]\n if (iti > x){\n count = i\n break\n }\n }\n if (x < l[0]) count = 1\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1590077814, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Kotlin/s636430213.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s636430213", "user_id": "u385678999"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var iti = 0\n var count = 0\n for (i in 1 until n+1){\n iti += l[i-1]\n if (iti > x){\n count = i\n break\n }\n }\n if (x < l[0]) count = 1\n println(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 357, "cpu_time_ms": 237, "memory_kb": 37868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s206135680", "group_id": "codeNet:p03000", "input_text": "package B\n\nfun main(args: Array) {\n val (n, x) = listOfInt()\n val lList = listOfInt()\n var sum = 0\n var cnt = 0\n for (i in 0 until n) {\n sum += lList[i]\n cnt++\n if (sum > x) break\n }\n println(cnt)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }", "language": "Kotlin", "metadata": {"date": 1562621354, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Kotlin/s206135680.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s206135680", "user_id": "u979004569"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "package B\n\nfun main(args: Array) {\n val (n, x) = listOfInt()\n val lList = listOfInt()\n var sum = 0\n var cnt = 0\n for (i in 0 until n) {\n sum += lList[i]\n cnt++\n if (sum > x) break\n }\n println(cnt)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 371, "cpu_time_ms": 162, "memory_kb": 29348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s913220825", "group_id": "codeNet:p03000", "input_text": "import java.lang.Integer.parseInt\nimport java.util.*\n\nfun main(args: Array) {\n val argList = Scanner(System.`in`)\n\n val arg = argList.nextLine().split(\" \")\n var N = parseInt(arg[0])\n val X = parseInt(arg[1])\n val L = argList.nextLine().split(\" \").map { parseInt(it) }\n\n var count = 0\n var current = 0\n\n L.forEach {\n if (current <= X) {\n count++\n current += it\n }\n \n if (L.size == N) return\n }\n\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1560973409, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Kotlin/s913220825.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s913220825", "user_id": "u156266692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.lang.Integer.parseInt\nimport java.util.*\n\nfun main(args: Array) {\n val argList = Scanner(System.`in`)\n\n val arg = argList.nextLine().split(\" \")\n var N = parseInt(arg[0])\n val X = parseInt(arg[1])\n val L = argList.nextLine().split(\" \").map { parseInt(it) }\n\n var count = 0\n var current = 0\n\n L.forEach {\n if (current <= X) {\n count++\n current += it\n }\n \n if (L.size == N) return\n }\n\n println(count)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 222, "memory_kb": 34044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s245398141", "group_id": "codeNet:p03000", "input_text": "import java.util.Scanner\n\nfun main(args: Array){\n val scn = Scanner(System.`in`) //Scannerのインスタンスを作成\n\n val n = scn.nextInt()\n val x = scn.nextInt()\n \n var boundNum = 0\n var distance = 0\n \n while(distance <= x && boundNum < n){\n boundNum++\n distance = distance + scn.nextInt()\n }\n if(distance <= x && boundNum == n){\n boundNum++\n }\n println(boundNum)\n}", "language": "Kotlin", "metadata": {"date": 1560713182, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Kotlin/s245398141.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s245398141", "user_id": "u595973568"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array){\n val scn = Scanner(System.`in`) //Scannerのインスタンスを作成\n\n val n = scn.nextInt()\n val x = scn.nextInt()\n \n var boundNum = 0\n var distance = 0\n \n while(distance <= x && boundNum < n){\n boundNum++\n distance = distance + scn.nextInt()\n }\n if(distance <= x && boundNum == n){\n boundNum++\n }\n println(boundNum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 436, "cpu_time_ms": 189, "memory_kb": 29724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s071704466", "group_id": "codeNet:p03000", "input_text": "fun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map(String::toInt)\n val ln = readLine()!!.split(\" \").map(String::toInt)\n\n val dn = mutableListOf(0)\n for (i in 1..n) {\n dn.add(dn[i - 1] + ln[i - 1])\n }\n println(dn.count { it <= x })\n}\n", "language": "Kotlin", "metadata": {"date": 1560712443, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Kotlin/s071704466.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071704466", "user_id": "u903745185"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map(String::toInt)\n val ln = readLine()!!.split(\" \").map(String::toInt)\n\n val dn = mutableListOf(0)\n for (i in 1..n) {\n dn.add(dn[i - 1] + ln[i - 1])\n }\n println(dn.count { it <= x })\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 240, "memory_kb": 36152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s197826145", "group_id": "codeNet:p03001", "input_text": "fun main(args: Array){\n val (w, h, x, y) = readLine()!!.split(\" \").map { it.toInt() }\n println(\"${w * h / 2.0} ${if(x*2 == w && y*2 == h) 1 else 0}\")\n}", "language": "Kotlin", "metadata": {"date": 1590001825, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Kotlin/s197826145.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s197826145", "user_id": "u531770859"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "fun main(args: Array){\n val (w, h, x, y) = readLine()!!.split(\" \").map { it.toInt() }\n println(\"${w * h / 2.0} ${if(x*2 == w && y*2 == h) 1 else 0}\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 165, "cpu_time_ms": 233, "memory_kb": 37900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s506299928", "group_id": "codeNet:p03001", "input_text": "fun main(args : Array) {\n val (W, H, x, y) = readLine()!!.split(\" \").map { it.toDouble() }\n\n val medX = W / 2.0\n val medY = H / 2.0\n val answer = W * H / 2.0\n if (x == medX && y == medY) {\n println(answer.toString() + \" 1\")\n } else {\n println(answer.toString() + \" 0\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1560722032, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Kotlin/s506299928.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s506299928", "user_id": "u861095163"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "fun main(args : Array) {\n val (W, H, x, y) = readLine()!!.split(\" \").map { it.toDouble() }\n\n val medX = W / 2.0\n val medY = H / 2.0\n val answer = W * H / 2.0\n if (x == medX && y == medY) {\n println(answer.toString() + \" 1\")\n } else {\n println(answer.toString() + \" 0\")\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 239, "memory_kb": 37980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s255476677", "group_id": "codeNet:p03001", "input_text": "fun main(args: Array) {\n val (w, h, x, y) = readLine()!!.split(\" \").map(String::toLong)\n\n val s = w * h\n\n if ((x == 0L && y == 0L) || (x == w && y == 0L) || (x == 0L && y == h) || (x == w && y == h)) {\n val s = w * h * 0.5\n println(\"$s 1\")\n } else {\n val sFixedX = x * h\n val minA = Math.min(sFixedX, s - sFixedX)\n\n val sFixedY = y * w\n val minB = Math.min(sFixedY, s - sFixedY)\n\n println(\"${Math.max(minA, minB)} ${if (minA == minB) 1 else 0}\") \n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1560717533, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Kotlin/s255476677.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s255476677", "user_id": "u903745185"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "fun main(args: Array) {\n val (w, h, x, y) = readLine()!!.split(\" \").map(String::toLong)\n\n val s = w * h\n\n if ((x == 0L && y == 0L) || (x == w && y == 0L) || (x == 0L && y == h) || (x == w && y == h)) {\n val s = w * h * 0.5\n println(\"$s 1\")\n } else {\n val sFixedX = x * h\n val minA = Math.min(sFixedX, s - sFixedX)\n\n val sFixedY = y * w\n val minB = Math.min(sFixedY, s - sFixedY)\n\n println(\"${Math.max(minA, minB)} ${if (minA == minB) 1 else 0}\") \n }\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 527, "cpu_time_ms": 237, "memory_kb": 37728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s436533554", "group_id": "codeNet:p03001", "input_text": "fun main(args: Array) {\n val inputs = readLine()!!.split(\" \").map(String::toInt)\n val W = inputs[0]\n val H = inputs[1]\n val x = inputs[2]\n val y = inputs[3]\n\n val isSome = W == H\n\n // x = [x]\n val xArea = (Math.min(x, W - x) * H).toDouble()\n // y = [y]\n val yArea = (W * Math.min(y, H - y)).toDouble()\n\n val area = Math.max(xArea, yArea)\n println(String.format(\"%f %d\", area, if (isSome) 1 else 0))\n}", "language": "Kotlin", "metadata": {"date": 1560717504, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Kotlin/s436533554.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s436533554", "user_id": "u938650438"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "fun main(args: Array) {\n val inputs = readLine()!!.split(\" \").map(String::toInt)\n val W = inputs[0]\n val H = inputs[1]\n val x = inputs[2]\n val y = inputs[3]\n\n val isSome = W == H\n\n // x = [x]\n val xArea = (Math.min(x, W - x) * H).toDouble()\n // y = [y]\n val yArea = (W * Math.min(y, H - y)).toDouble()\n\n val area = Math.max(xArea, yArea)\n println(String.format(\"%f %d\", area, if (isSome) 1 else 0))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 444, "cpu_time_ms": 259, "memory_kb": 38000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s940118074", "group_id": "codeNet:p03006", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\ndata class Point(val x: Int, val y: Int)\ndata class Delta(val x: Int, val y: Int)\n\nfun solve() {\n val n = readInteger()\n val pointArray = Array(n) {\n val (x, y) = readIntegerList()\n Point(x, y)\n }.sortedWith(compareBy({ it.x }, { it.y }))\n\n val deltaMap = mutableMapOf()\n for (i in pointArray.indices) {\n for (j in (i + 1) until pointArray.size) {\n val delta = Delta(pointArray[j].x - pointArray[i].x, pointArray[j].y - pointArray[i].y)\n deltaMap.merge(delta, 1) { old, new -> old + new}\n }\n }\n val mostCommonDelta = deltaMap.entries.maxBy { it.value }!!.key\n\n val checkedPointHash = mutableMapOf()\n for (p in pointArray) {\n checkedPointHash[p] = false\n }\n\n var ans = 0\n for ((i, p) in pointArray.withIndex()) {\n if (checkedPointHash[p]!!) {\n continue\n }\n ans++\n checkedPointHash[p] = true\n\n var prePoint = p\n while (true) {\n val nextPoint = Point(prePoint.x + mostCommonDelta.x, prePoint.y + mostCommonDelta.y)\n if (checkedPointHash[nextPoint] == null) {\n break\n }\n\n checkedPointHash[nextPoint] = true\n prePoint = nextPoint\n }\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1595793248, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03006.html", "problem_id": "p03006", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03006/input.txt", "sample_output_relpath": "derived/input_output/data/p03006/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03006/Kotlin/s940118074.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s940118074", "user_id": "u784448849"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\ndata class Point(val x: Int, val y: Int)\ndata class Delta(val x: Int, val y: Int)\n\nfun solve() {\n val n = readInteger()\n val pointArray = Array(n) {\n val (x, y) = readIntegerList()\n Point(x, y)\n }.sortedWith(compareBy({ it.x }, { it.y }))\n\n val deltaMap = mutableMapOf()\n for (i in pointArray.indices) {\n for (j in (i + 1) until pointArray.size) {\n val delta = Delta(pointArray[j].x - pointArray[i].x, pointArray[j].y - pointArray[i].y)\n deltaMap.merge(delta, 1) { old, new -> old + new}\n }\n }\n val mostCommonDelta = deltaMap.entries.maxBy { it.value }!!.key\n\n val checkedPointHash = mutableMapOf()\n for (p in pointArray) {\n checkedPointHash[p] = false\n }\n\n var ans = 0\n for ((i, p) in pointArray.withIndex()) {\n if (checkedPointHash[p]!!) {\n continue\n }\n ans++\n checkedPointHash[p] = true\n\n var prePoint = p\n while (true) {\n val nextPoint = Point(prePoint.x + mostCommonDelta.x, prePoint.y + mostCommonDelta.y)\n if (checkedPointHash[nextPoint] == null) {\n break\n }\n\n checkedPointHash[nextPoint] = true\n prePoint = nextPoint\n }\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "sample_input": "2\n1 1\n2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03006", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1941, "cpu_time_ms": 131, "memory_kb": 40356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s922310231", "group_id": "codeNet:p03006", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val cnt = mutableListOf>()\n val ab = (1..n).map {\n val x = readLine()!!.split(\" \").map { it.toInt() }\n Pair(x[0], x[1])\n }.sortedBy { it.first }\n var m = 0\n for (i in 0 until n - 1) {\n for (j in i + 1 until n) {\n val x = ab[j].first - ab[i].first\n val y = ab[j].second - ab[i].second\n cnt.add(Pair(x, y))\n }\n }\n for ((i, j) in cnt) {\n m = Math.max(m, cnt.count { it == Pair(i, j) })\n }\n println(n - m)\n}", "language": "Kotlin", "metadata": {"date": 1560648973, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03006.html", "problem_id": "p03006", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03006/input.txt", "sample_output_relpath": "derived/input_output/data/p03006/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03006/Kotlin/s922310231.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s922310231", "user_id": "u122997134"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val cnt = mutableListOf>()\n val ab = (1..n).map {\n val x = readLine()!!.split(\" \").map { it.toInt() }\n Pair(x[0], x[1])\n }.sortedBy { it.first }\n var m = 0\n for (i in 0 until n - 1) {\n for (j in i + 1 until n) {\n val x = ab[j].first - ab[i].first\n val y = ab[j].second - ab[i].second\n cnt.add(Pair(x, y))\n }\n }\n for ((i, j) in cnt) {\n m = Math.max(m, cnt.count { it == Pair(i, j) })\n }\n println(n - m)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "sample_input": "2\n1 1\n2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03006", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 579, "cpu_time_ms": 302, "memory_kb": 52632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s268308797", "group_id": "codeNet:p03011", "input_text": "fun main(args: Array) {\n val (p, q, r) = readLine()!!.split(\" \").map { it.toInt() }\n\n var ans = Int.MAX_VALUE\n\n ans = Math.min(ans, p + q)\n ans = Math.min(ans, q + r)\n ans = Math.min(ans, p + r)\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1560128562, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03011/input.txt", "sample_output_relpath": "derived/input_output/data/p03011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03011/Kotlin/s268308797.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s268308797", "user_id": "u889750959"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (p, q, r) = readLine()!!.split(\" \").map { it.toInt() }\n\n var ans = Int.MAX_VALUE\n\n ans = Math.min(ans, p + q)\n ans = Math.min(ans, q + r)\n ans = Math.min(ans, p + r)\n\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 237, "cpu_time_ms": 241, "memory_kb": 37744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s608297307", "group_id": "codeNet:p03011", "input_text": "fun main(args: Array) {\n val xs = readLine()!!.split(' ').map { it.toInt() }\n val ans = xs.sorted().take(2).sum()\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1560128515, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03011/input.txt", "sample_output_relpath": "derived/input_output/data/p03011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03011/Kotlin/s608297307.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s608297307", "user_id": "u863309603"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val xs = readLine()!!.split(' ').map { it.toInt() }\n val ans = xs.sorted().take(2).sum()\n println(ans)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 251, "memory_kb": 37920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s583959977", "group_id": "codeNet:p03012", "input_text": "fun main (args : Array) {\n\tval n = readLine()\n\tval N : Int = n!!.toInt()\n\tval list = readLine()!!.split(\" \").map(String::toInt)\n\tvar wList : MutableList = mutableListOf()\n\tvar S1 : Int = 0\n\tvar S2 : Int = 0\n\tvar T : Int = 0\n\tvar calc : Int = 0\n\tvar result : Int = 0\n\tfor (i in 0..N - 1) {\n\t\twList.add(list[i])\n\t}\n\tfor (i in 0..N - 1) {\n\t\tT = i\n\t\tfor (j in 0..T) {\n\t\t\tS1 += wList[j]\n\t\t}\n\t\tfor (k in N - 1 downTo T + 1) {\n\t\t\tS2 += wList[k]\n\t\t}\n\t\t\t\n\t\tif (i == 0) {\n\t\t\tresult = S2 - S1\n\t\t}\n\t\t\n\t\tcalc = S2 - S1\n\t\tif (calc < 0) {\n\t\t\tcalc = -(calc)\n\t\t}\n\t\t\n\t\tif (result >= calc) {\n\t\t\tresult = calc\n\t\t\tS1 = 0\n\t\t\tS2 = 0\n\t\t} else {\n\t\t\tS1 = 0\n\t\t\tS2 = 0\n\t\t}\n\t\t\n\t}\n\tprintln(\"${result}\")\n}", "language": "Kotlin", "metadata": {"date": 1560132353, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03012.html", "problem_id": "p03012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03012/input.txt", "sample_output_relpath": "derived/input_output/data/p03012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03012/Kotlin/s583959977.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s583959977", "user_id": "u651257341"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "fun main (args : Array) {\n\tval n = readLine()\n\tval N : Int = n!!.toInt()\n\tval list = readLine()!!.split(\" \").map(String::toInt)\n\tvar wList : MutableList = mutableListOf()\n\tvar S1 : Int = 0\n\tvar S2 : Int = 0\n\tvar T : Int = 0\n\tvar calc : Int = 0\n\tvar result : Int = 0\n\tfor (i in 0..N - 1) {\n\t\twList.add(list[i])\n\t}\n\tfor (i in 0..N - 1) {\n\t\tT = i\n\t\tfor (j in 0..T) {\n\t\t\tS1 += wList[j]\n\t\t}\n\t\tfor (k in N - 1 downTo T + 1) {\n\t\t\tS2 += wList[k]\n\t\t}\n\t\t\t\n\t\tif (i == 0) {\n\t\t\tresult = S2 - S1\n\t\t}\n\t\t\n\t\tcalc = S2 - S1\n\t\tif (calc < 0) {\n\t\t\tcalc = -(calc)\n\t\t}\n\t\t\n\t\tif (result >= calc) {\n\t\t\tresult = calc\n\t\t\tS1 = 0\n\t\t\tS2 = 0\n\t\t} else {\n\t\t\tS1 = 0\n\t\t\tS2 = 0\n\t\t}\n\t\t\n\t}\n\tprintln(\"${result}\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N weights indexed 1 to N. The \bmass of the weight indexed i is W_i.\n\nWe will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \\leq T < N. Let S_1 be the sum of the masses of the weights in the former group, and S_2 be the sum of the masses of the weights in the latter group.\n\nConsider all possible such divisions and find the minimum possible absolute difference of S_1 and S_2.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq W_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nW_1 W_2 ... W_{N-1} W_N\n\nOutput\n\nPrint the minimum possible absolute difference of S_1 and S_2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n0\n\nIf T = 2, S_1 = 1 + 2 = 3 and S_2 = 3, with the absolute difference of 0.\n\nSample Input 2\n\n4\n1 3 1 1\n\nSample Output 2\n\n2\n\nIf T = 2, S_1 = 1 + 3 = 4 and S_2 = 1 + 1 = 2, with the absolute difference of 2. We cannot have a smaller absolute difference.\n\nSample Input 3\n\n8\n27 23 76 2 3 5 62 52\n\nSample Output 3\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03012", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N weights indexed 1 to N. The \bmass of the weight indexed i is W_i.\n\nWe will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \\leq T < N. Let S_1 be the sum of the masses of the weights in the former group, and S_2 be the sum of the masses of the weights in the latter group.\n\nConsider all possible such divisions and find the minimum possible absolute difference of S_1 and S_2.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq W_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nW_1 W_2 ... W_{N-1} W_N\n\nOutput\n\nPrint the minimum possible absolute difference of S_1 and S_2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n0\n\nIf T = 2, S_1 = 1 + 2 = 3 and S_2 = 3, with the absolute difference of 0.\n\nSample Input 2\n\n4\n1 3 1 1\n\nSample Output 2\n\n2\n\nIf T = 2, S_1 = 1 + 3 = 4 and S_2 = 1 + 1 = 2, with the absolute difference of 2. We cannot have a smaller absolute difference.\n\nSample Input 3\n\n8\n27 23 76 2 3 5 62 52\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 687, "cpu_time_ms": 254, "memory_kb": 37932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s267368747", "group_id": "codeNet:p03013", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = (0 until m).map { \n sc.nextInt()\n }\n\n abc129c(n, a)\n}\n\nfun abc129c(n: Int, a: List) {\n val safe = BooleanArray(n + 1) { true }\n for (ai in a) {\n safe[ai] = false\n }\n val dp = LongArray(n + 1) { 0 }\n dp[0] = 1L\n if (safe[1]) dp[1] = 1L\n for (i in 2..n) {\n if (safe[i - 2]) dp[i] += dp[i - 2]\n if (safe[i - 1]) dp[i] += dp[i - 1]\n } \n val mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()\n val ans: Long = dp[n] % mod\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1581828936, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Kotlin/s267368747.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s267368747", "user_id": "u323522006"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = (0 until m).map { \n sc.nextInt()\n }\n\n abc129c(n, a)\n}\n\nfun abc129c(n: Int, a: List) {\n val safe = BooleanArray(n + 1) { true }\n for (ai in a) {\n safe[ai] = false\n }\n val dp = LongArray(n + 1) { 0 }\n dp[0] = 1L\n if (safe[1]) dp[1] = 1L\n for (i in 2..n) {\n if (safe[i - 2]) dp[i] += dp[i - 2]\n if (safe[i - 1]) dp[i] += dp[i - 1]\n } \n val mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()\n val ans: Long = dp[n] % mod\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 651, "cpu_time_ms": 559, "memory_kb": 51252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s167247987", "group_id": "codeNet:p03013", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = (0 until m).map { \n sc.nextInt()\n }\n\n abc129c(n, a)\n}\n\nfun abc129c(n: Int, a: List) {\n val safe = BooleanArray(n + 1) { true }\n for (ai in a) {\n safe[ai] = false\n }\n val dp = LongArray(n + 1) { 0 }\n dp[0] = 1\n if (safe[1]) {\n dp[1] = 1\n }\n for (i in 2..n) {\n if (safe[i - 1]) dp[i] += dp[i - 1]\n if (safe[i - 2]) dp[i] += dp[i - 2]\n } \n val MOD = 1000000007\n println(dp[n] % MOD)\n}\n", "language": "Kotlin", "metadata": {"date": 1581827484, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Kotlin/s167247987.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s167247987", "user_id": "u323522006"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = (0 until m).map { \n sc.nextInt()\n }\n\n abc129c(n, a)\n}\n\nfun abc129c(n: Int, a: List) {\n val safe = BooleanArray(n + 1) { true }\n for (ai in a) {\n safe[ai] = false\n }\n val dp = LongArray(n + 1) { 0 }\n dp[0] = 1\n if (safe[1]) {\n dp[1] = 1\n }\n for (i in 2..n) {\n if (safe[i - 1]) dp[i] += dp[i - 1]\n if (safe[i - 2]) dp[i] += dp[i - 2]\n } \n val MOD = 1000000007\n println(dp[n] % MOD)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 611, "cpu_time_ms": 547, "memory_kb": 53400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s874820837", "group_id": "codeNet:p03013", "input_text": "import java.lang.Math.*\nimport kotlin.comparisons.compareByDescending\n\nconst val MOD = 1000000007L\nconst val INF = 1000000007L\n\nfun main(args: Array) {\n val (n, m) = readIntList()\n\n val a = Array(n + 1) {\n return@Array true\n }\n m.rep {\n val t = readInt()\n a[t] = false\n }\n\n val memo = Array(n + 1) {\n return@Array 0L\n }\n\n fun dfs(now: Int): Long {\n if (now == n) {\n return 1\n }\n \n if (memo[now] > 0L) {\n return memo[now]\n }\n\n var ret = 0L\n if (now + 1 < n + 1 && a[now + 1]) {\n ret += dfs(now + 1)\n }\n if (now + 2 < n + 1 && a[now + 2]) {\n ret += dfs(now + 2)\n }\n memo[now] = ret % MOD\n return memo[now]\n }\n\n println(dfs(0))\n\n}\n\nfun readList() = readLine()!!.split(' ')\nfun readInt() = readLine()!!.split(' ').map(String::toInt).first()\nfun readIntList() = readList().map(String::toInt)\nfun readLongList() = readList().map(String::toLong)\nfun readDoubleList() = readList().map(String::toDouble)\n\nfun readPair(): Pair {\n val splite = readLine()!!.split(' ')\n return Pair(splite[0], splite[1])\n}\n\nfun List.copy() = this.map { it }\n\ninline fun dualArray(h: Int, w: Int, init: (Int, Int) -> T) {\n Array(h) { i ->\n return@Array Array(w) { j ->\n return@Array init(i, j)\n }\n }\n}\n\n// 速度のためforEachは避ける\ninline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\ninline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = sqrt(value.toDouble()).toLong()\n val former = mutableListOf()\n val latter = mutableListOf()\n (1..max).filter { value % it == 0L }\n .forEach {\n former.add(it)\n latter.add(value / it)\n }\n former.addAll(latter.reversed())\n return former\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\n// 二分探索\nfun List.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {\n var start = (_start - 1).toLong()\n var end = _end.toLong()\n while (end - start > 1) {\n val mid = (start + end) / 2\n if (this[mid.toInt()] < target) {\n start = mid\n } else {\n end = mid\n }\n }\n return end.toInt()\n}\n\n// bit全探索\ninline fun Int.bitAllSearch(body: (Array) -> Unit) {\n for (bit in 0 until (1 shl this)) {\n val s = mutableListOf()\n for (i in 0 until this) {\n if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか\n s.add(i)\n }\n }\n body(s.toTypedArray())\n }\n}", "language": "Kotlin", "metadata": {"date": 1565664236, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Kotlin/s874820837.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s874820837", "user_id": "u718935188"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.lang.Math.*\nimport kotlin.comparisons.compareByDescending\n\nconst val MOD = 1000000007L\nconst val INF = 1000000007L\n\nfun main(args: Array) {\n val (n, m) = readIntList()\n\n val a = Array(n + 1) {\n return@Array true\n }\n m.rep {\n val t = readInt()\n a[t] = false\n }\n\n val memo = Array(n + 1) {\n return@Array 0L\n }\n\n fun dfs(now: Int): Long {\n if (now == n) {\n return 1\n }\n \n if (memo[now] > 0L) {\n return memo[now]\n }\n\n var ret = 0L\n if (now + 1 < n + 1 && a[now + 1]) {\n ret += dfs(now + 1)\n }\n if (now + 2 < n + 1 && a[now + 2]) {\n ret += dfs(now + 2)\n }\n memo[now] = ret % MOD\n return memo[now]\n }\n\n println(dfs(0))\n\n}\n\nfun readList() = readLine()!!.split(' ')\nfun readInt() = readLine()!!.split(' ').map(String::toInt).first()\nfun readIntList() = readList().map(String::toInt)\nfun readLongList() = readList().map(String::toLong)\nfun readDoubleList() = readList().map(String::toDouble)\n\nfun readPair(): Pair {\n val splite = readLine()!!.split(' ')\n return Pair(splite[0], splite[1])\n}\n\nfun List.copy() = this.map { it }\n\ninline fun dualArray(h: Int, w: Int, init: (Int, Int) -> T) {\n Array(h) { i ->\n return@Array Array(w) { j ->\n return@Array init(i, j)\n }\n }\n}\n\n// 速度のためforEachは避ける\ninline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\ninline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = sqrt(value.toDouble()).toLong()\n val former = mutableListOf()\n val latter = mutableListOf()\n (1..max).filter { value % it == 0L }\n .forEach {\n former.add(it)\n latter.add(value / it)\n }\n former.addAll(latter.reversed())\n return former\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\n// 二分探索\nfun List.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {\n var start = (_start - 1).toLong()\n var end = _end.toLong()\n while (end - start > 1) {\n val mid = (start + end) / 2\n if (this[mid.toInt()] < target) {\n start = mid\n } else {\n end = mid\n }\n }\n return end.toInt()\n}\n\n// bit全探索\ninline fun Int.bitAllSearch(body: (Array) -> Unit) {\n for (bit in 0 until (1 shl this)) {\n val s = mutableListOf()\n for (i in 0 until this) {\n if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか\n s.add(i)\n }\n }\n body(s.toTypedArray())\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3814, "cpu_time_ms": 2111, "memory_kb": 53540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s662090682", "group_id": "codeNet:p03014", "input_text": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val h = sc.nextInt()\n val w = sc.nextInt()\n val fs = '.'.toInt()\n\n val map = Array(h) {\n IntArray(w) {\n sc.readByteAsInt() - fs\n }.let {\n sc.readByte()\n it\n }\n }\n\n for((height, row) in map.withIndex()) {\n var lastWall = -1\n for ((width, c) in row.withIndex()) {\n if (c < 0) {\n if (lastWall != width - 1) {\n val len = width - lastWall - 1\n for (i in (lastWall + 1) until width) {\n map[height][i] = len\n }\n }\n lastWall = width\n }\n }\n\n if (lastWall != w - 1) {\n val len = w - lastWall - 1\n for (i in (lastWall + 1) until w) {\n map[height][i] = len\n }\n }\n }\n\n for (width in 0 until w) {\n var lastWall = -1\n for (height in 0 until h) {\n val c = map[height][width]\n if (c < 0) {\n if (lastWall != height - 1) {\n val len = height - lastWall - 1\n for (i in (lastWall + 1) until height) {\n map[i][width] += len\n }\n }\n lastWall = height\n }\n }\n\n if (lastWall != h - 1) {\n val len = h - lastWall - 1\n for (i in (lastWall + 1) until h) {\n map[i][width] += len\n }\n }\n }\n\n var max = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n val v = map[i][j]\n if (v > max) max = v\n }\n }\n\n out.println(max - 1)\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(2048)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object : CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private inline fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private inline fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589789216, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03014/input.txt", "sample_output_relpath": "derived/input_output/data/p03014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03014/Kotlin/s662090682.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662090682", "user_id": "u996672406"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "@file:Suppress(\"DuplicatedCode\")\n\nimport java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.NoSuchElementException\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n D.solve(D.FastScanner(), out)\n out.flush()\n }\n}\n\nprivate fun D.solve(sc: D.FastScanner, out: PrintWriter) {\n val h = sc.nextInt()\n val w = sc.nextInt()\n val fs = '.'.toInt()\n\n val map = Array(h) {\n IntArray(w) {\n sc.readByteAsInt() - fs\n }.let {\n sc.readByte()\n it\n }\n }\n\n for((height, row) in map.withIndex()) {\n var lastWall = -1\n for ((width, c) in row.withIndex()) {\n if (c < 0) {\n if (lastWall != width - 1) {\n val len = width - lastWall - 1\n for (i in (lastWall + 1) until width) {\n map[height][i] = len\n }\n }\n lastWall = width\n }\n }\n\n if (lastWall != w - 1) {\n val len = w - lastWall - 1\n for (i in (lastWall + 1) until w) {\n map[height][i] = len\n }\n }\n }\n\n for (width in 0 until w) {\n var lastWall = -1\n for (height in 0 until h) {\n val c = map[height][width]\n if (c < 0) {\n if (lastWall != height - 1) {\n val len = height - lastWall - 1\n for (i in (lastWall + 1) until height) {\n map[i][width] += len\n }\n }\n lastWall = height\n }\n }\n\n if (lastWall != h - 1) {\n val len = h - lastWall - 1\n for (i in (lastWall + 1) until h) {\n map[i][width] += len\n }\n }\n }\n\n var max = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n val v = map[i][j]\n if (v > max) max = v\n }\n }\n\n out.println(max - 1)\n}\n\n@Suppress(\"MemberVisibilityCanBePrivate\")\nprivate object D {\n private const val zeroCode = '0'.toInt()\n private const val nineCode = '9'.toInt()\n\n class FastScanner {\n private val `in`: InputStream = System.`in`\n private val buffer = ByteArray(2048)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n\n fun readByteAsInt(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++\n return hasNextByte()\n }\n\n operator fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n\n return buildString {\n var b = readByteAsInt()\n\n while (isPrintableChar(b)) {\n appendCodePoint(b)\n b = readByteAsInt()\n }\n }\n }\n\n fun toCharIterator(): CharIterator = object : CharIterator() {\n private var nextByte: Byte = readByte()\n\n override fun hasNext(): Boolean = isPrintableChar(nextByte)\n\n override fun nextChar(): Char {\n val res = nextByte\n nextByte = readByte()\n return res.toChar()\n }\n\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByteAsInt()\n\n if (b == '-'.toInt()) {\n minus = true\n b = readByteAsInt()\n }\n\n if (b !in zeroCode..nineCode) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in zeroCode..nineCode) {\n n *= 10\n n += b - zeroCode.toLong()\n } else if (b == -1 || !isPrintableChar(b)) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n\n b = readByteAsInt()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return next().toDouble()\n }\n\n fun readIntArray(n: Int): IntArray {\n val arr = IntArray(n)\n\n for (i in 0 until n) {\n arr[i] = nextInt()\n }\n\n return arr\n }\n\n fun readBigInt(capacity: Int): IntArray {\n if (!hasNext()) throw NoSuchElementException()\n\n val arr = IntArray(capacity)\n var len = 0\n arr[0] = readByteAsInt() - zeroCode\n while (arr[len] in 0..9) {\n len++\n arr[len] = readByteAsInt() - zeroCode\n }\n\n return arr.sliceArray(0 until len)\n }\n\n companion object {\n private inline fun isPrintableChar(c: Int): Boolean {\n return c in 33..126\n }\n\n private inline fun isPrintableChar(c: Byte): Boolean {\n return c in 33..126\n }\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "sample_input": "4 6\n#..#..\n.....#\n....#.\n#.#...\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03014", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5847, "cpu_time_ms": 489, "memory_kb": 73376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s200977960", "group_id": "codeNet:p03014", "input_text": "fun main(args: Array) {\n /**\n * 解説を見てみると,回答方針はあっていた模様,どこの処理が遅い書き方になっていて TLEになっていたのか分析する\n */\n\n\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n\n val inputs = mutableListOf()\n\n // bufferedReader を使えば早くなりそう?? と思ったが RE が発生してしまい使えなかった\n\n // map を使うと処理に時間がかかって間に合わなくなる??\n for (i in 0 until h) {\n val line = readLine()!!\n inputs.add(line)\n }\n\n val fieldHorizontal = Array(h) { IntArray(w) { 1 } }\n val fieldVertical = Array(h) { IntArray(w) { 1 } }\n\n // 横方向へ塗っていく\n for (i in 0 until h) {\n for (j in 1 until w) {\n // 岩はスキップ\n\n if (inputs[i][j] == '#') {\n fieldHorizontal[i][j] = 0\n continue\n }\n\n fieldHorizontal[i][j] = fieldHorizontal[i][j - 1] + 1\n }\n }\n\n // 塗った結果を逆方向から反映させていく\n for (i in 0 until h) {\n var maxTmp = fieldHorizontal[i][w - 1]\n for (j in w - 2 downTo 0) {\n // 岩はスキップ\n if (inputs[i][j] == '#') {\n maxTmp = 0\n continue\n }\n maxTmp = Math.max(maxTmp, fieldHorizontal[i][j])\n fieldHorizontal[i][j] = maxTmp\n }\n }\n\n\n // 縦方向へ塗っていく\n for (j in 0 until w) {\n for (i in 1 until h) {\n // 岩はスキップ\n if (inputs[i][j] == '#') {\n fieldVertical[i][j] = 0\n continue\n }\n fieldVertical[i][j] = fieldVertical[i - 1][j] + 1\n }\n }\n\n // 塗った結果を逆方向から反映させていく\n for (j in 0 until w) {\n var maxTmp = fieldVertical[h - 1][j]\n for (i in h - 2 downTo 0) {\n // 岩はスキップ\n if (inputs[i][j] == '#') {\n maxTmp = 0\n continue\n }\n maxTmp = Math.max(maxTmp, fieldVertical[i][j])\n fieldVertical[i][j] = maxTmp\n }\n }\n\n\n var ans = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n ans = Math.max(ans, fieldHorizontal[i][j] + fieldVertical[i][j])\n }\n }\n\n println(ans - 1)\n}", "language": "Kotlin", "metadata": {"date": 1560219509, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03014/input.txt", "sample_output_relpath": "derived/input_output/data/p03014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03014/Kotlin/s200977960.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200977960", "user_id": "u889750959"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n /**\n * 解説を見てみると,回答方針はあっていた模様,どこの処理が遅い書き方になっていて TLEになっていたのか分析する\n */\n\n\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n\n val inputs = mutableListOf()\n\n // bufferedReader を使えば早くなりそう?? と思ったが RE が発生してしまい使えなかった\n\n // map を使うと処理に時間がかかって間に合わなくなる??\n for (i in 0 until h) {\n val line = readLine()!!\n inputs.add(line)\n }\n\n val fieldHorizontal = Array(h) { IntArray(w) { 1 } }\n val fieldVertical = Array(h) { IntArray(w) { 1 } }\n\n // 横方向へ塗っていく\n for (i in 0 until h) {\n for (j in 1 until w) {\n // 岩はスキップ\n\n if (inputs[i][j] == '#') {\n fieldHorizontal[i][j] = 0\n continue\n }\n\n fieldHorizontal[i][j] = fieldHorizontal[i][j - 1] + 1\n }\n }\n\n // 塗った結果を逆方向から反映させていく\n for (i in 0 until h) {\n var maxTmp = fieldHorizontal[i][w - 1]\n for (j in w - 2 downTo 0) {\n // 岩はスキップ\n if (inputs[i][j] == '#') {\n maxTmp = 0\n continue\n }\n maxTmp = Math.max(maxTmp, fieldHorizontal[i][j])\n fieldHorizontal[i][j] = maxTmp\n }\n }\n\n\n // 縦方向へ塗っていく\n for (j in 0 until w) {\n for (i in 1 until h) {\n // 岩はスキップ\n if (inputs[i][j] == '#') {\n fieldVertical[i][j] = 0\n continue\n }\n fieldVertical[i][j] = fieldVertical[i - 1][j] + 1\n }\n }\n\n // 塗った結果を逆方向から反映させていく\n for (j in 0 until w) {\n var maxTmp = fieldVertical[h - 1][j]\n for (i in h - 2 downTo 0) {\n // 岩はスキップ\n if (inputs[i][j] == '#') {\n maxTmp = 0\n continue\n }\n maxTmp = Math.max(maxTmp, fieldVertical[i][j])\n fieldVertical[i][j] = maxTmp\n }\n }\n\n\n var ans = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n ans = Math.max(ans, fieldHorizontal[i][j] + fieldVertical[i][j])\n }\n }\n\n println(ans - 1)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "sample_input": "4 6\n#..#..\n.....#\n....#.\n#.#...\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03014", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2430, "cpu_time_ms": 690, "memory_kb": 97328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s300265741", "group_id": "codeNet:p03017", "input_text": "fun main(args: Array) {\n val (n,a,b,c,d) = readLine()!!.split(\" \").map { it.toInt()-1 }\n val s = readLine()!!\n\n if(c) {\n val (n,a,b,c,d) = readLine()!!.split(\" \").map { it.toInt()-1 }\n val s = readLine()!!\n\n if(c) {\n val line = readLine()!!.split(\" \").map { it.toInt() }\n val a = line[1]\n val b = line[2]\n val c = line[3]\n val d = line[4]\n val s = readLine()!!\n val str = s.substring(0,if(c>d)c-1 else d-1)\n if(str.contains(\"##\")){\n println(\"No\")\n return\n }\n if((a>b&&c>d) || (ab) a else b\n val targetmin = if(c=targetmin-1){\n println(\"No\")\n }else{\n println(\"Yes\")\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1559529311, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Kotlin/s818211452.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s818211452", "user_id": "u943726499"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n val line = readLine()!!.split(\" \").map { it.toInt() }\n val a = line[1]\n val b = line[2]\n val c = line[3]\n val d = line[4]\n val s = readLine()!!\n val str = s.substring(0,if(c>d)c-1 else d-1)\n if(str.contains(\"##\")){\n println(\"No\")\n return\n }\n if((a>b&&c>d) || (ab) a else b\n val targetmin = if(c=targetmin-1){\n println(\"No\")\n }else{\n println(\"Yes\")\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 725, "cpu_time_ms": 281, "memory_kb": 39592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s096582568", "group_id": "codeNet:p03017", "input_text": "fun main(args:Array) {\n val line = readLine()!!.split(\" \").map { it.toInt() }\n val a = line[1]\n val b = line[2]\n val c = line[3]\n val d = line[4]\n val str = readLine()!!\n if(str.contains(\"##\")){\n println(\"NO\")\n return\n }\n if((a>b&&c>d) || (ab) a else b\n val targetmin = if(c=targetmin){\n println(\"NO\")\n }else{\n println(\"YES\")\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1559526288, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Kotlin/s096582568.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s096582568", "user_id": "u943726499"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n val line = readLine()!!.split(\" \").map { it.toInt() }\n val a = line[1]\n val b = line[2]\n val c = line[3]\n val d = line[4]\n val str = readLine()!!\n if(str.contains(\"##\")){\n println(\"NO\")\n return\n }\n if((a>b&&c>d) || (ab) a else b\n val targetmin = if(c=targetmin){\n println(\"NO\")\n }else{\n println(\"YES\")\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 678, "cpu_time_ms": 279, "memory_kb": 41464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s532910418", "group_id": "codeNet:p03017", "input_text": "fun main(args:Array) {\n val line = readLine()!!.split(\" \").map { it.toInt() }\n val a = line[1]\n val b = line[2]\n val c = line[3]\n val d = line[4]\n val str = readLine()!!\n if(str.contains(\"##\")){\n println(\"NO\")\n return\n }\n if((a>b&&c>d) || (a=targetmin){\n println(\"NO\")\n }else{\n println(\"YES\")\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1559525997, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Kotlin/s532910418.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s532910418", "user_id": "u943726499"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n val line = readLine()!!.split(\" \").map { it.toInt() }\n val a = line[1]\n val b = line[2]\n val c = line[3]\n val d = line[4]\n val str = readLine()!!\n if(str.contains(\"##\")){\n println(\"NO\")\n return\n }\n if((a>b&&c>d) || (a=targetmin){\n println(\"NO\")\n }else{\n println(\"YES\")\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 668, "cpu_time_ms": 282, "memory_kb": 41324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s967178581", "group_id": "codeNet:p03024", "input_text": "fun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val s = sc.next()\n\n println(if (s.toCharArray().filter { c -> c == 'x' }.count() < 8) \"YES\" else \"NO\")\n}\n", "language": "Kotlin", "metadata": {"date": 1559437893, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03024.html", "problem_id": "p03024", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03024/input.txt", "sample_output_relpath": "derived/input_output/data/p03024/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03024/Kotlin/s967178581.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s967178581", "user_id": "u059223549"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val s = sc.next()\n\n println(if (s.toCharArray().filter { c -> c == 'x' }.count() < 8) \"YES\" else \"NO\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is competing in a sumo tournament.\nThe tournament lasts for 15 days, during which he performs in one match per day.\nIf he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished.\nYou are given the results of Takahashi's matches as a string S consisting of o and x.\nIf the i-th character in S is o, it means that Takahashi won the match on the i-th day; if that character is x, it means that Takahashi lost the match on the i-th day.\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO if there is no such possibility.\n\nConstraints\n\n1 \\leq k \\leq 15\n\nS is a string of length k consisting of o and x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO otherwise.\n\nSample Input 1\n\noxoxoxoxoxoxox\n\nSample Output 1\n\nYES\n\nTakahashi has 7 wins and 7 losses before the last match. If he wins that match, he will have 8 wins.\n\nSample Input 2\n\nxxxxxxxx\n\nSample Output 2\n\nNO", "sample_input": "oxoxoxoxoxoxox\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03024", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is competing in a sumo tournament.\nThe tournament lasts for 15 days, during which he performs in one match per day.\nIf he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished.\nYou are given the results of Takahashi's matches as a string S consisting of o and x.\nIf the i-th character in S is o, it means that Takahashi won the match on the i-th day; if that character is x, it means that Takahashi lost the match on the i-th day.\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO if there is no such possibility.\n\nConstraints\n\n1 \\leq k \\leq 15\n\nS is a string of length k consisting of o and x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO otherwise.\n\nSample Input 1\n\noxoxoxoxoxoxox\n\nSample Output 1\n\nYES\n\nTakahashi has 7 wins and 7 losses before the last match. If he wins that match, he will have 8 wins.\n\nSample Input 2\n\nxxxxxxxx\n\nSample Output 2\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 188, "cpu_time_ms": 187, "memory_kb": 31516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s922303214", "group_id": "codeNet:p03025", "input_text": "fun main(args: Array) {\n val mod = 1000000007\n fun pow(x: Long, y: Long): Long {\n if (y == 0L) {\n return 1L\n } else if (y % 2 == 0L) {\n val a = pow(x, y / 2)\n return a * a % mod\n } else {\n val a = pow(x, y / 2)\n return a * a % mod * x % mod\n }\n }\n\n fun div(x: Long, y: Long): Long {\n return x * pow(y, (mod - 2).toLong()) % mod\n }\n\n val (n, a, b, c) = readLine()!!.split(' ').map(String::toLong)\n val aPct = div(a, a + b)\n val bPct = div(b, a + b)\n\n var comb = 1L\n var ans = 0L\n for (i in 0 until n) {\n ans += pow(aPct, n) * pow(bPct, i) % mod * comb % mod * (n + i) % mod\n ans %= mod.toLong()\n ans += pow(bPct, n) * pow(aPct, i) % mod * comb % mod * (n + i) % mod\n ans %= mod.toLong()\n comb = div(comb * (n + i) % mod, (i + 1))\n }\n val l = div(a + b, 100)\n println(div(ans, l))\n}\n", "language": "Kotlin", "metadata": {"date": 1559449234, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03025.html", "problem_id": "p03025", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03025/input.txt", "sample_output_relpath": "derived/input_output/data/p03025/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03025/Kotlin/s922303214.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s922303214", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val mod = 1000000007\n fun pow(x: Long, y: Long): Long {\n if (y == 0L) {\n return 1L\n } else if (y % 2 == 0L) {\n val a = pow(x, y / 2)\n return a * a % mod\n } else {\n val a = pow(x, y / 2)\n return a * a % mod * x % mod\n }\n }\n\n fun div(x: Long, y: Long): Long {\n return x * pow(y, (mod - 2).toLong()) % mod\n }\n\n val (n, a, b, c) = readLine()!!.split(' ').map(String::toLong)\n val aPct = div(a, a + b)\n val bPct = div(b, a + b)\n\n var comb = 1L\n var ans = 0L\n for (i in 0 until n) {\n ans += pow(aPct, n) * pow(bPct, i) % mod * comb % mod * (n + i) % mod\n ans %= mod.toLong()\n ans += pow(bPct, n) * pow(aPct, i) % mod * comb % mod * (n + i) % mod\n ans %= mod.toLong()\n comb = div(comb * (n + i) % mod, (i + 1))\n }\n val l = div(a + b, 100)\n println(div(ans, l))\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.\nFind the expected number of games that will be played, and print it as follows.\n\nWe can represent the expected value as P/Q with coprime integers P and Q.\nPrint the integer R between 0 and 10^9+6 (inclusive) such that R \\times Q \\equiv P\\pmod {10^9+7}.\n(Such an integer R always uniquely exists under the constraints of this problem.)\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A,B,C \\leq 100\n\n1 \\leq A+B\n\nA+B+C=100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\n\nOutput\n\nPrint the expected number of games that will be played, in the manner specified in the statement.\n\nSample Input 1\n\n1 25 25 50\n\nSample Output 1\n\n2\n\nSince N=1, they will repeat the game until one of them wins.\nThe expected number of games played is 2.\n\nSample Input 2\n\n4 50 50 0\n\nSample Output 2\n\n312500008\n\nC may be 0.\n\nSample Input 3\n\n1 100 0 0\n\nSample Output 3\n\n1\n\nB may also be 0.\n\nSample Input 4\n\n100000 31 41 28\n\nSample Output 4\n\n104136146", "sample_input": "1 25 25 50\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03025", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.\nFind the expected number of games that will be played, and print it as follows.\n\nWe can represent the expected value as P/Q with coprime integers P and Q.\nPrint the integer R between 0 and 10^9+6 (inclusive) such that R \\times Q \\equiv P\\pmod {10^9+7}.\n(Such an integer R always uniquely exists under the constraints of this problem.)\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A,B,C \\leq 100\n\n1 \\leq A+B\n\nA+B+C=100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\n\nOutput\n\nPrint the expected number of games that will be played, in the manner specified in the statement.\n\nSample Input 1\n\n1 25 25 50\n\nSample Output 1\n\n2\n\nSince N=1, they will repeat the game until one of them wins.\nThe expected number of games played is 2.\n\nSample Input 2\n\n4 50 50 0\n\nSample Output 2\n\n312500008\n\nC may be 0.\n\nSample Input 3\n\n1 100 0 0\n\nSample Output 3\n\n1\n\nB may also be 0.\n\nSample Input 4\n\n100000 31 41 28\n\nSample Output 4\n\n104136146", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 956, "cpu_time_ms": 526, "memory_kb": 40676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s496603242", "group_id": "codeNet:p03026", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n\n val g = Graph(N, 0, 1e8.toInt()) {a, b -> a + b}\n\n for (i in 1 until N) {\n val (a, b) = readLine()!!.split(\" \").map{it.toInt() - 1}\n\n g.edges[a].add(Edge(a, b, 1))\n g.edges[b].add(Edge(b, a, 1))\n }\n\n val c = readLine()!!.split(\" \").map{it.toLong()}.sorted()\n\n val d = Array(N) { g.edges[it].size }\n val used = Array(N) { false }\n val ans = Array(N) { -1L }\n\n for (t in c.indices) {\n var idx = -1\n var mx = 1e18.toInt()\n\n for (i in d.indices) {\n if (used[i]) continue\n\n if (mx > d[i]) {\n mx = d[i]\n idx = i\n }\n }\n\n for (e in g.edges[idx]) {\n d[e.to]--\n }\n used[idx] = true\n ans[idx] = c[t]\n }\n\n var res = 0L\n for (i in g.edges.indices) for (e in g.edges[i]) {\n if (e.from > e.to) continue\n\n res += Math.min(ans[e.from], ans[e.to])\n }\n\n println(res)\n println(ans.joinToString(\" \"))\n}\n\ndata class Edge>(val from: Int, val to: Int, val weight: T): Comparable> {\n constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)\n\n override fun compareTo(other: Edge) = weight.compareTo(other.weight)\n}\n\nclass Graph>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {\n val edges = Array(n) { ArrayList>() }\n}\n\ninline fun >dijkstra(g: Graph, s: Int): Pair, Array> {\n val N = g.n\n val dist = Array(N) { g.inf }\n val prev = Array(N) {-1}\n\n val Q = PriorityQueue>()\n\n dist[s] = g.zero\n Q.add(Edge(-2, s, g.zero))\n\n while(Q.isNotEmpty()) {\n val e = Q.peek()\n val v = e.to\n Q.poll()\n\n if (prev[v] != -1) continue\n prev[v] = e.from\n for (i in g.edges[v]) {\n val d = g.plus(dist[v], i.weight)\n if (dist[i.to] > d) {\n dist[i.to] = d\n Q.add(Edge(i.from, i.to, d))\n }\n }\n }\n\n return Pair(dist, prev)\n}\n", "language": "Kotlin", "metadata": {"date": 1578196632, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03026.html", "problem_id": "p03026", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03026/input.txt", "sample_output_relpath": "derived/input_output/data/p03026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03026/Kotlin/s496603242.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496603242", "user_id": "u183530284"}, "prompt_components": {"gold_output": "10\n1 2 3 4 5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n\n val g = Graph(N, 0, 1e8.toInt()) {a, b -> a + b}\n\n for (i in 1 until N) {\n val (a, b) = readLine()!!.split(\" \").map{it.toInt() - 1}\n\n g.edges[a].add(Edge(a, b, 1))\n g.edges[b].add(Edge(b, a, 1))\n }\n\n val c = readLine()!!.split(\" \").map{it.toLong()}.sorted()\n\n val d = Array(N) { g.edges[it].size }\n val used = Array(N) { false }\n val ans = Array(N) { -1L }\n\n for (t in c.indices) {\n var idx = -1\n var mx = 1e18.toInt()\n\n for (i in d.indices) {\n if (used[i]) continue\n\n if (mx > d[i]) {\n mx = d[i]\n idx = i\n }\n }\n\n for (e in g.edges[idx]) {\n d[e.to]--\n }\n used[idx] = true\n ans[idx] = c[t]\n }\n\n var res = 0L\n for (i in g.edges.indices) for (e in g.edges[i]) {\n if (e.from > e.to) continue\n\n res += Math.min(ans[e.from], ans[e.to])\n }\n\n println(res)\n println(ans.joinToString(\" \"))\n}\n\ndata class Edge>(val from: Int, val to: Int, val weight: T): Comparable> {\n constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)\n\n override fun compareTo(other: Edge) = weight.compareTo(other.weight)\n}\n\nclass Graph>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {\n val edges = Array(n) { ArrayList>() }\n}\n\ninline fun >dijkstra(g: Graph, s: Int): Pair, Array> {\n val N = g.n\n val dist = Array(N) { g.inf }\n val prev = Array(N) {-1}\n\n val Q = PriorityQueue>()\n\n dist[s] = g.zero\n Q.add(Edge(-2, s, g.zero))\n\n while(Q.isNotEmpty()) {\n val e = Q.peek()\n val v = e.to\n Q.poll()\n\n if (prev[v] != -1) continue\n prev[v] = e.from\n for (i in g.edges[v]) {\n val d = g.plus(dist[v], i.weight)\n if (dist[i.to] > d) {\n dist[i.to] = d\n Q.add(Edge(i.from, i.to, d))\n }\n }\n }\n\n return Pair(dist, prev)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a tree with N vertices 1,2,\\ldots,N, and positive integers c_1,c_2,\\ldots,c_N.\nThe i-th edge in the tree (1 \\leq i \\leq N-1) connects Vertex a_i and Vertex b_i.\n\nWe will write a positive integer on each vertex in T and calculate our score as follows:\n\nOn each edge, write the smaller of the integers written on the two endpoints.\n\nLet our score be the sum of the integers written on all the edges.\n\nFind the maximum possible score when we write each of c_1,c_2,\\ldots,c_N on one vertex in T, and show one way to achieve it. If an integer occurs multiple times in c_1,c_2,\\ldots,c_N, we must use it that number of times.\n\nConstraints\n\n1 \\leq N \\leq 10000\n\n1 \\leq a_i,b_i \\leq N\n\n1 \\leq c_i \\leq 10^5\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nc_1 \\ldots c_N\n\nOutput\n\nUse the following format:\n\nM\nd_1 \\ldots d_N\n\nwhere M is the maximum possible score, and d_i is the integer to write on Vertex i.\nd_1,d_2,\\ldots,d_N must be a permutation of c_1,c_2,\\ldots,c_N.\nIf there are multiple ways to achieve the maximum score, any of them will be accepted.\n\nSample Input 1\n\n5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n\nSample Output 1\n\n10\n1 2 3 4 5\n\nIf we write 1,2,3,4,5 on Vertex 1,2,3,4,5, respectively, the integers written on the four edges will be 1,2,3,4, for the score of 10. This is the maximum possible score.\n\nSample Input 2\n\n5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n\nSample Output 2\n\n197\n59 26 3141 59 53\n\nc_1,c_2,\\ldots,c_N may not be pairwise distinct.", "sample_input": "5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n"}, "reference_outputs": ["10\n1 2 3 4 5\n"], "source_document_id": "p03026", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a tree with N vertices 1,2,\\ldots,N, and positive integers c_1,c_2,\\ldots,c_N.\nThe i-th edge in the tree (1 \\leq i \\leq N-1) connects Vertex a_i and Vertex b_i.\n\nWe will write a positive integer on each vertex in T and calculate our score as follows:\n\nOn each edge, write the smaller of the integers written on the two endpoints.\n\nLet our score be the sum of the integers written on all the edges.\n\nFind the maximum possible score when we write each of c_1,c_2,\\ldots,c_N on one vertex in T, and show one way to achieve it. If an integer occurs multiple times in c_1,c_2,\\ldots,c_N, we must use it that number of times.\n\nConstraints\n\n1 \\leq N \\leq 10000\n\n1 \\leq a_i,b_i \\leq N\n\n1 \\leq c_i \\leq 10^5\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nc_1 \\ldots c_N\n\nOutput\n\nUse the following format:\n\nM\nd_1 \\ldots d_N\n\nwhere M is the maximum possible score, and d_i is the integer to write on Vertex i.\nd_1,d_2,\\ldots,d_N must be a permutation of c_1,c_2,\\ldots,c_N.\nIf there are multiple ways to achieve the maximum score, any of them will be accepted.\n\nSample Input 1\n\n5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n\nSample Output 1\n\n10\n1 2 3 4 5\n\nIf we write 1,2,3,4,5 on Vertex 1,2,3,4,5, respectively, the integers written on the four edges will be 1,2,3,4, for the score of 10. This is the maximum possible score.\n\nSample Input 2\n\n5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n\nSample Output 2\n\n197\n59 26 3141 59 53\n\nc_1,c_2,\\ldots,c_N may not be pairwise distinct.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2162, "cpu_time_ms": 970, "memory_kb": 50600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s902494053", "group_id": "codeNet:p03030", "input_text": "import java.util.*\nimport kotlin.comparisons.*\n\nfun main(args : Array) {\n val n = readLine()!!.toInt()\n val comp = compareBy(Triple::second).thenByDescending(Triple::third)\n val r = sortedSetOf(comp)\n repeat(n) {\n val (s, p) = readLine()!!.split(' ')\n r.add(Triple(it + 1, s, p.toInt()))\n }\n r.forEach { println(it.first) }\n}\n", "language": "Kotlin", "metadata": {"date": 1587092692, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/Kotlin/s902494053.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s902494053", "user_id": "u051841332"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "import java.util.*\nimport kotlin.comparisons.*\n\nfun main(args : Array) {\n val n = readLine()!!.toInt()\n val comp = compareBy(Triple::second).thenByDescending(Triple::third)\n val r = sortedSetOf(comp)\n repeat(n) {\n val (s, p) = readLine()!!.split(' ')\n r.add(Triple(it + 1, s, p.toInt()))\n }\n r.forEach { println(it.first) }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 382, "cpu_time_ms": 246, "memory_kb": 35952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s777252157", "group_id": "codeNet:p03030", "input_text": "import java.util.*\nclass Shop(name: String, point: Int, number: Int) {\n val dict = name + \" \" +(100-point).toString()\n val number = number\n}\n\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val a: MutableList = mutableListOf()\n for (i in 1..n) {\n a.add(Shop(cin.next(), cin.nextInt(), i))\n } \n val a_s = a.sortedBy { it.dict }\n for (i in 0..n-1) {\n println(a_s[i].number)\n }\n}", "language": "Kotlin", "metadata": {"date": 1558921289, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/Kotlin/s777252157.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s777252157", "user_id": "u111421568"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "import java.util.*\nclass Shop(name: String, point: Int, number: Int) {\n val dict = name + \" \" +(100-point).toString()\n val number = number\n}\n\nfun main(args: Array){\n\tval cin = Scanner(System.`in`)\n val n = cin.nextInt()\n val a: MutableList = mutableListOf()\n for (i in 1..n) {\n a.add(Shop(cin.next(), cin.nextInt(), i))\n } \n val a_s = a.sortedBy { it.dict }\n for (i in 0..n-1) {\n println(a_s[i].number)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 476, "cpu_time_ms": 254, "memory_kb": 34172}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s483316362", "group_id": "codeNet:p03030", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val spList = mutableListOf>()\n (1..n).forEach {\n val (s,p) = readLine()!!.split(' ')\n spList.add(Triple(s,p.toInt(),it))\n }\n spList.sortByDescending { it.second }\n spList.sortBy { it.first }\n spList.forEach { println(it.third) }\n}\n", "language": "Kotlin", "metadata": {"date": 1558919079, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/Kotlin/s483316362.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s483316362", "user_id": "u099066216"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val spList = mutableListOf>()\n (1..n).forEach {\n val (s,p) = readLine()!!.split(' ')\n spList.add(Triple(s,p.toInt(),it))\n }\n spList.sortByDescending { it.second }\n spList.sortBy { it.first }\n spList.forEach { println(it.third) }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 352, "cpu_time_ms": 289, "memory_kb": 38112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s885648078", "group_id": "codeNet:p03031", "input_text": "fun main(args: Array) {\n val (n, m) = readIntegerList()\n val lampInfoArray = Array(m) { readIntegerList() }\n val pList = readIntegerList()\n\n var ans = 0\n for (switchState in 0 until (1 shl n)) {\n if (isAllOn(switchState, n, m, lampInfoArray, pList)) {\n ans++\n }\n }\n\n println(ans)\n}\n\nfun isAllOn(switchState: Int, n: Int, m: Int, lampInfoArray: Array>, pList: List): Boolean {\n for (i in 0 until m) {\n if (isOff(switchState, lampInfoArray[i], pList[i])) {\n return false\n }\n }\n\n return true\n}\n\nfun isOff(switchState: Int, lampInfo: List, p: Int): Boolean {\n var count = 0\n for (i in lampInfo.drop(1)) {\n if (((switchState shr (i - 1)) and 1) == 1) {\n count++\n }\n }\n\n return if ((count % 2) == p) false else true\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1582591588, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03031/input.txt", "sample_output_relpath": "derived/input_output/data/p03031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03031/Kotlin/s885648078.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s885648078", "user_id": "u784448849"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readIntegerList()\n val lampInfoArray = Array(m) { readIntegerList() }\n val pList = readIntegerList()\n\n var ans = 0\n for (switchState in 0 until (1 shl n)) {\n if (isAllOn(switchState, n, m, lampInfoArray, pList)) {\n ans++\n }\n }\n\n println(ans)\n}\n\nfun isAllOn(switchState: Int, n: Int, m: Int, lampInfoArray: Array>, pList: List): Boolean {\n for (i in 0 until m) {\n if (isOff(switchState, lampInfoArray[i], pList[i])) {\n return false\n }\n }\n\n return true\n}\n\nfun isOff(switchState: Int, lampInfo: List, p: Int): Boolean {\n var count = 0\n for (i in lampInfo.drop(1)) {\n if (((switchState shr (i - 1)) and 1) == 1) {\n count++\n }\n }\n\n return if ((count % 2) == p) false else true\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "sample_input": "2 2\n2 1 2\n1 2\n0 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03031", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1103, "cpu_time_ms": 284, "memory_kb": 38000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s829749617", "group_id": "codeNet:p03032", "input_text": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\n////////////////////////////////////////////////////////////////////////\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val K = sc.next().toInt()\n val V = Array(N) { sc.next().toLong() }\n var ans = 0L\n for (a in 0..arrayOf(N, K).min()!!) {\n for (b in 0..(arrayOf(N, K).min()!! - a)) {\n if (a + b == 0) continue\n val pq = PriorityQueue()\n pq.addAll(V.take(a))\n pq.addAll(V.drop(N - b))\n var s = pq.sum()\n if (ans < s) ans = s\n repeat(K - (a + b)) {\n if (pq.isNotEmpty()) {\n val n = pq.first()\n pq.remove(n)\n s -= n\n if (ans < s) ans = s\n }\n }\n }\n }\n pw.println(ans)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1588644461, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03032.html", "problem_id": "p03032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03032/input.txt", "sample_output_relpath": "derived/input_output/data/p03032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03032/Kotlin/s829749617.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829749617", "user_id": "u297767059"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\n////////////////////////////////////////////////////////////////////////\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val K = sc.next().toInt()\n val V = Array(N) { sc.next().toLong() }\n var ans = 0L\n for (a in 0..arrayOf(N, K).min()!!) {\n for (b in 0..(arrayOf(N, K).min()!! - a)) {\n if (a + b == 0) continue\n val pq = PriorityQueue()\n pq.addAll(V.take(a))\n pq.addAll(V.drop(N - b))\n var s = pq.sum()\n if (ans < s) ans = s\n repeat(K - (a + b)) {\n if (pq.isNotEmpty()) {\n val n = pq.first()\n pq.remove(n)\n s -= n\n if (ans < s) ans = s\n }\n }\n }\n }\n pw.println(ans)\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "sample_input": "6 4\n-10 8 2 1 2 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03032", "source_text": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1646, "cpu_time_ms": 373, "memory_kb": 40400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s569658087", "group_id": "codeNet:p03032", "input_text": "fun main(arg: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toInt)\n val po = readLine()!!.split(' ').map(String::toInt)\n var score = -1000000000\n (0..k).forEach { i1 ->\n (0..Math.min(i1, n)).forEach { i2 ->\n (0..i2).forEach { i3 ->\n (0..i1 - i2).forEach { i4 ->\n val meu = (po.take(i3) + po.drop(n - (i2 - i3))).sorted().drop(i4).sum()\n score = Math.max(score, meu)\n }\n }\n }\n }\n println(score)\n}\n", "language": "Kotlin", "metadata": {"date": 1559509577, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03032.html", "problem_id": "p03032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03032/input.txt", "sample_output_relpath": "derived/input_output/data/p03032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03032/Kotlin/s569658087.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s569658087", "user_id": "u880126159"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main(arg: Array) {\n val (n, k) = readLine()!!.split(' ').map(String::toInt)\n val po = readLine()!!.split(' ').map(String::toInt)\n var score = -1000000000\n (0..k).forEach { i1 ->\n (0..Math.min(i1, n)).forEach { i2 ->\n (0..i2).forEach { i3 ->\n (0..i1 - i2).forEach { i4 ->\n val meu = (po.take(i3) + po.drop(n - (i2 - i3))).sorted().drop(i4).sum()\n score = Math.max(score, meu)\n }\n }\n }\n }\n println(score)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "sample_input": "6 4\n-10 8 2 1 2 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03032", "source_text": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 539, "cpu_time_ms": 2111, "memory_kb": 119476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s143638203", "group_id": "codeNet:p03032", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val vs = readLine()!!.split(\" \").map { it.toInt() }\n var max = 0\n for (s in 0..n) {\n for (t in s..n) {\n val ws = mutableListOf()\n for (i in 0 until s) {\n ws.add(vs[i])\n }\n for (i in t until n) {\n ws.add(vs[i])\n }\n if (ws.size > k) continue\n ws.sort()\n for (i in 0 until Math.min(ws.size, k - ws.size)) {\n if (ws[i] < 0) {\n ws[i] = 0\n }\n }\n max = Math.max(max, ws.sum())\n }\n }\n println(max)\n}", "language": "Kotlin", "metadata": {"date": 1558920678, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03032.html", "problem_id": "p03032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03032/input.txt", "sample_output_relpath": "derived/input_output/data/p03032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03032/Kotlin/s143638203.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143638203", "user_id": "u771276542"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val vs = readLine()!!.split(\" \").map { it.toInt() }\n var max = 0\n for (s in 0..n) {\n for (t in s..n) {\n val ws = mutableListOf()\n for (i in 0 until s) {\n ws.add(vs[i])\n }\n for (i in t until n) {\n ws.add(vs[i])\n }\n if (ws.size > k) continue\n ws.sort()\n for (i in 0 until Math.min(ws.size, k - ws.size)) {\n if (ws[i] < 0) {\n ws[i] = 0\n }\n }\n max = Math.max(max, ws.sum())\n }\n }\n println(max)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "sample_input": "6 4\n-10 8 2 1 2 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03032", "source_text": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 585, "cpu_time_ms": 328, "memory_kb": 39544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s712058639", "group_id": "codeNet:p03033", "input_text": "import java.util.*\n\nprivate data class Work(val start: Int, val end: Int, val dist: Int)\nprivate data class Position(val pos: Int, val index: Int)\n\nfun main(args: Array) {\n\n /**\n * 同等のデータ構造, ロジックを実装しているが TLE で通らない,, java と kotlin の速度差?? どう分析するべきか\n * WAをあえて出すと実行時間を出力できる\n *\n * -> !! 最後の出力形式を for 文から joinToString に変えると一気に早くなってAC\n */\n val (n, q) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 工事を格納 O(N)\n var workList = mutableListOf()\n\n for (i in 0 until n) {\n val (s, t, x) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 切り上げ,切り捨てをして閉区間で考える\n var start = Math.ceil(s - 0.5 - x).toInt()\n var end = Math.floor(t - 0.5 - x).toInt()\n\n workList.add(Work(start, end, x))\n }\n\n // 工事を距離が近い順にソート O(NlogN)\n workList.sortBy { it.dist }\n\n // スタート地点を配列に保持する(最初からソートされて渡されるのでソートの必要なし) O(N)\n // スタート地点の中で,ある工事区間に含まれるものを取り出し,配列から削除,\n var posSet = TreeSet { a, b -> a.pos - b.pos } // Comparator をラムダ式で渡す\n for (i in 0 until q) {\n posSet.add(Position(readLine()!!.toInt(), i))\n }\n\n\n // 答えにはデフォルトで -1 を設定 (選ばれなかったものは工事に合わない = -1 )\n val ans = IntArray(q) { -1 }\n\n\n for (work in workList) {\n\n // work.start よりも大きな開始地点を持つ posList 内の 最初の要素を指す イテレータを取得\n // O(logN)\n val comp = Position(work.start, -1)\n var position = posSet.ceiling(comp)\n\n // 工事に含まれる位置にいる posList の要素を取得し,削除\n while (position != null) {\n if (position.pos > work.end) {\n break\n }\n\n // O(logN)\n posSet.remove(position)\n\n // O(1)\n ans[position.index] = work.dist\n\n position = posSet.ceiling(comp)\n }\n }\n\n println(ans.joinToString(\"\\n\"))\n// for (a in ans) {\n// println(a)\n// }\n}", "language": "Kotlin", "metadata": {"date": 1559414543, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03033/input.txt", "sample_output_relpath": "derived/input_output/data/p03033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03033/Kotlin/s712058639.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s712058639", "user_id": "u889750959"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "import java.util.*\n\nprivate data class Work(val start: Int, val end: Int, val dist: Int)\nprivate data class Position(val pos: Int, val index: Int)\n\nfun main(args: Array) {\n\n /**\n * 同等のデータ構造, ロジックを実装しているが TLE で通らない,, java と kotlin の速度差?? どう分析するべきか\n * WAをあえて出すと実行時間を出力できる\n *\n * -> !! 最後の出力形式を for 文から joinToString に変えると一気に早くなってAC\n */\n val (n, q) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 工事を格納 O(N)\n var workList = mutableListOf()\n\n for (i in 0 until n) {\n val (s, t, x) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 切り上げ,切り捨てをして閉区間で考える\n var start = Math.ceil(s - 0.5 - x).toInt()\n var end = Math.floor(t - 0.5 - x).toInt()\n\n workList.add(Work(start, end, x))\n }\n\n // 工事を距離が近い順にソート O(NlogN)\n workList.sortBy { it.dist }\n\n // スタート地点を配列に保持する(最初からソートされて渡されるのでソートの必要なし) O(N)\n // スタート地点の中で,ある工事区間に含まれるものを取り出し,配列から削除,\n var posSet = TreeSet { a, b -> a.pos - b.pos } // Comparator をラムダ式で渡す\n for (i in 0 until q) {\n posSet.add(Position(readLine()!!.toInt(), i))\n }\n\n\n // 答えにはデフォルトで -1 を設定 (選ばれなかったものは工事に合わない = -1 )\n val ans = IntArray(q) { -1 }\n\n\n for (work in workList) {\n\n // work.start よりも大きな開始地点を持つ posList 内の 最初の要素を指す イテレータを取得\n // O(logN)\n val comp = Position(work.start, -1)\n var position = posSet.ceiling(comp)\n\n // 工事に含まれる位置にいる posList の要素を取得し,削除\n while (position != null) {\n if (position.pos > work.end) {\n break\n }\n\n // O(logN)\n posSet.remove(position)\n\n // O(1)\n ans[position.index] = work.dist\n\n position = posSet.ceiling(comp)\n }\n }\n\n println(ans.joinToString(\"\\n\"))\n// for (a in ans) {\n// println(a)\n// }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "sample_input": "4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n"}, "reference_outputs": ["2\n2\n10\n-1\n13\n-1\n"], "source_document_id": "p03033", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2384, "cpu_time_ms": 1385, "memory_kb": 133448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s293181410", "group_id": "codeNet:p03033", "input_text": "private data class Work(val start: Int, val end: Int, val dist: Int)\nprivate data class Position(val pos: Int, val index: Int)\n\nfun main(args: Array) {\n val (n, q) = readLine()!!.split(\" \").map { it.toInt() }\n\n // イベントソート\n\n\n // segTree ライブラリがあればいけるとのこと\n // RMQ とは??\n\n\n // 工事を格納\n var workList = mutableListOf()\n\n for (i in 0 until n) {\n val (s, t, x) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 切り上げ,切り捨てをして閉区間で考える\n var start = Math.ceil(s - 0.5 - x).toInt()\n var end = Math.floor(t - 0.5 - x).toInt()\n\n workList.add(Work(start, end, x))\n }\n\n // 工事を距離が近い順にソート\n workList.sortBy { it.dist }\n\n // スタート地点を配列に保持してソート\n // スタート地点の中で,ある工事区間に含まれるものを取り出し,配列から削除,\n var posList = mutableListOf()\n for (i in 0 until q) {\n posList.add(Position(readLine()!!.toInt(), i))\n }\n\n // 開始地点を近い順にソート\n posList.sortBy { it.pos }\n\n // 答えにはデフォルトで -1 を設定 (選ばれなかったものは工事に合わない = -1 )\n val ans = IntArray(q) { -1 }\n\n\n /////////////////////////////////////////////////\n // 探索を開始\n /////////////////////////////////////////////////\n\n // n = 10^5 ループが回る\n // ループ内ではまず log N = log 10^5 探索\n // while ループが回る数は合計で q = 10^5\n // なので全体のオーダーとしては O(NlogN) くらいになるはず だがTLEなのはなぜか??\n\n for (i in 0 until n) {\n\n val work = workList[i]\n\n // work.start よりも大きな開始地点を持つ posList 内の 最初のインデックスを取得\n // binarySearch を用いて実装する必要がある\n val j = getLowerBound(posList, work.start)\n\n\n while (true) {\n // WA: 配列が空になってしまう場合を考慮漏れ\n if (posList.isEmpty() || j >= posList.size || posList[j].pos > work.end) {\n break\n }\n\n // 工事の範囲に収まる開始点を持つ人を判別, 行ける最短の距離を割り当てる\n ans[posList[j].index] = work.dist\n\n // 該当の人を削除する & 次の要素に進む操作が必要 & かならずしも先頭からではない & 毎回削除していくことで探索コストを抑えることだできる\n // やはり繰り返しの中で動的に要素数を変更していきたい\n // 懸念点インデックス j でのイテレーションが面倒かもしれない -> 最後に removeAll でまとめて削除すれば j についてのループでは心配しなくて良いかも??\n // 削除すれば それはつまり1つ進んだことと同じ\n\n posList.removeAt((j))\n\n if (posList.isEmpty()) {\n break\n }\n }\n }\n\n for( a in ans){\n println(a)\n }\n}\n\nprivate fun getLowerBound(data: MutableList, boundary: Int): Int {\n\n // 該当値のインデックス, もしくはその値を挿入するならどこになるかを示してくれている\n // 空の配列に対して操作した場合は??\n val index = data.binarySearch { it.pos - boundary }\n\n if (index >= 0) {\n return index\n }\n return -1 * index - 1\n}", "language": "Kotlin", "metadata": {"date": 1559353596, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03033/input.txt", "sample_output_relpath": "derived/input_output/data/p03033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03033/Kotlin/s293181410.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s293181410", "user_id": "u889750959"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "private data class Work(val start: Int, val end: Int, val dist: Int)\nprivate data class Position(val pos: Int, val index: Int)\n\nfun main(args: Array) {\n val (n, q) = readLine()!!.split(\" \").map { it.toInt() }\n\n // イベントソート\n\n\n // segTree ライブラリがあればいけるとのこと\n // RMQ とは??\n\n\n // 工事を格納\n var workList = mutableListOf()\n\n for (i in 0 until n) {\n val (s, t, x) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 切り上げ,切り捨てをして閉区間で考える\n var start = Math.ceil(s - 0.5 - x).toInt()\n var end = Math.floor(t - 0.5 - x).toInt()\n\n workList.add(Work(start, end, x))\n }\n\n // 工事を距離が近い順にソート\n workList.sortBy { it.dist }\n\n // スタート地点を配列に保持してソート\n // スタート地点の中で,ある工事区間に含まれるものを取り出し,配列から削除,\n var posList = mutableListOf()\n for (i in 0 until q) {\n posList.add(Position(readLine()!!.toInt(), i))\n }\n\n // 開始地点を近い順にソート\n posList.sortBy { it.pos }\n\n // 答えにはデフォルトで -1 を設定 (選ばれなかったものは工事に合わない = -1 )\n val ans = IntArray(q) { -1 }\n\n\n /////////////////////////////////////////////////\n // 探索を開始\n /////////////////////////////////////////////////\n\n // n = 10^5 ループが回る\n // ループ内ではまず log N = log 10^5 探索\n // while ループが回る数は合計で q = 10^5\n // なので全体のオーダーとしては O(NlogN) くらいになるはず だがTLEなのはなぜか??\n\n for (i in 0 until n) {\n\n val work = workList[i]\n\n // work.start よりも大きな開始地点を持つ posList 内の 最初のインデックスを取得\n // binarySearch を用いて実装する必要がある\n val j = getLowerBound(posList, work.start)\n\n\n while (true) {\n // WA: 配列が空になってしまう場合を考慮漏れ\n if (posList.isEmpty() || j >= posList.size || posList[j].pos > work.end) {\n break\n }\n\n // 工事の範囲に収まる開始点を持つ人を判別, 行ける最短の距離を割り当てる\n ans[posList[j].index] = work.dist\n\n // 該当の人を削除する & 次の要素に進む操作が必要 & かならずしも先頭からではない & 毎回削除していくことで探索コストを抑えることだできる\n // やはり繰り返しの中で動的に要素数を変更していきたい\n // 懸念点インデックス j でのイテレーションが面倒かもしれない -> 最後に removeAll でまとめて削除すれば j についてのループでは心配しなくて良いかも??\n // 削除すれば それはつまり1つ進んだことと同じ\n\n posList.removeAt((j))\n\n if (posList.isEmpty()) {\n break\n }\n }\n }\n\n for( a in ans){\n println(a)\n }\n}\n\nprivate fun getLowerBound(data: MutableList, boundary: Int): Int {\n\n // 該当値のインデックス, もしくはその値を挿入するならどこになるかを示してくれている\n // 空の配列に対して操作した場合は??\n val index = data.binarySearch { it.pos - boundary }\n\n if (index >= 0) {\n return index\n }\n return -1 * index - 1\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "sample_input": "4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n"}, "reference_outputs": ["2\n2\n10\n-1\n13\n-1\n"], "source_document_id": "p03033", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3572, "cpu_time_ms": 2111, "memory_kb": 125344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163168300", "group_id": "codeNet:p03035", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n\n return when {\n a < 6 -> {\n println(0)\n }\n a < 13 -> {\n println(b / 2)\n }\n else -> {\n println(b)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1583266052, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03035/input.txt", "sample_output_relpath": "derived/input_output/data/p03035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03035/Kotlin/s163168300.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163168300", "user_id": "u507286069"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map(String::toInt)\n\n return when {\n a < 6 -> {\n println(0)\n }\n a < 13 -> {\n println(b / 2)\n }\n else -> {\n println(b)\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 278, "cpu_time_ms": 235, "memory_kb": 37648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s029726978", "group_id": "codeNet:p03036", "input_text": "fun main(args: Array) {\n val (r, D, x) = readLine()!!.split(\" \").map(String::toInt)\n var a: Int\n for (i in 0..10) {\n a = r * x - D\n println(a)\n }\n}", "language": "Kotlin", "metadata": {"date": 1583266753, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03036/input.txt", "sample_output_relpath": "derived/input_output/data/p03036/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03036/Kotlin/s029726978.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s029726978", "user_id": "u507286069"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "fun main(args: Array) {\n val (r, D, x) = readLine()!!.split(\" \").map(String::toInt)\n var a: Int\n for (i in 0..10) {\n a = r * x - D\n println(a)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "sample_input": "2 10 20\n"}, "reference_outputs": ["30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"], "source_document_id": "p03036", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 181, "cpu_time_ms": 232, "memory_kb": 37828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s340410933", "group_id": "codeNet:p03037", "input_text": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main(args: Array) {\n val (n, m) = intList()\n var lMax = 0\n var rMin = Int.MAX_VALUE\n repeat(m) {\n val (l, r) = intList()\n lMax = Math.max(lMax, l)\n rMin = Math.min(rMin, r)\n }\n val result = Math.max(0, (rMin - lMax + 1))\n println(result.toString())\n}\n", "language": "Kotlin", "metadata": {"date": 1591473096, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Kotlin/s340410933.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340410933", "user_id": "u979429407"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main(args: Array) {\n val (n, m) = intList()\n var lMax = 0\n var rMin = Int.MAX_VALUE\n repeat(m) {\n val (l, r) = intList()\n lMax = Math.max(lMax, l)\n rMin = Math.min(rMin, r)\n }\n val result = Math.max(0, (rMin - lMax + 1))\n println(result.toString())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 374, "cpu_time_ms": 573, "memory_kb": 53928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s257914146", "group_id": "codeNet:p03037", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val lr = (0 until m).map {\n sc.next().toInt() to sc.next().toInt()\n }\n\n abc127c(n, m, lr)\n}\n\nfun abc127c(n: Int, m: Int, lr: List>){\n var mn = 1\n var mx = n\n for (i in 0 until m) {\n var lri = lr.get(i)\n mn = Math.max(mn, lri.first)\n mx = Math.min(mx, lri.second)\n }\n\n val ans = mx - mn + 1\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1581454915, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Kotlin/s257914146.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s257914146", "user_id": "u323522006"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val lr = (0 until m).map {\n sc.next().toInt() to sc.next().toInt()\n }\n\n abc127c(n, m, lr)\n}\n\nfun abc127c(n: Int, m: Int, lr: List>){\n var mn = 1\n var mx = n\n for (i in 0 until m) {\n var lri = lr.get(i)\n mn = Math.max(mn, lri.first)\n mx = Math.min(mx, lri.second)\n }\n\n val ans = mx - mn + 1\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 513, "cpu_time_ms": 702, "memory_kb": 59584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s468591827", "group_id": "codeNet:p03037", "input_text": "fun main(args: Array) {\n\n val (idCardAmount, gateAmount) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n val L = mutableListOf()\n val R = mutableListOf()\n val i = 0\n val LRList = mutableListOf>()\n\n for (i in 0 until gateAmount) {\n val (L_, R_) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n L.add(L_)\n R.add(R_)\n LRList.add(Pair(L_, R_))\n }\n val LMax = L.max()\n val RMin = R.min()\n LMax?.let {\n RMin?.let {\n print(Math.max(RMin - LMax + 1, 0))\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1558833945, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Kotlin/s468591827.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468591827", "user_id": "u039197338"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (idCardAmount, gateAmount) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n val L = mutableListOf()\n val R = mutableListOf()\n val i = 0\n val LRList = mutableListOf>()\n\n for (i in 0 until gateAmount) {\n val (L_, R_) = readLine()!!.split(\" \").map { Integer.parseInt(it) }\n L.add(L_)\n R.add(R_)\n LRList.add(Pair(L_, R_))\n }\n val LMax = L.max()\n val RMin = R.min()\n LMax?.let {\n RMin?.let {\n print(Math.max(RMin - LMax + 1, 0))\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 587, "cpu_time_ms": 654, "memory_kb": 66472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s454101822", "group_id": "codeNet:p03037", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val (l, r) = readLine()!!.split(' ').map(String::toInt)\n var a = (l..r).toSet()\n repeat(m - 1) {\n val (l2, r2) = readLine()!!.split(' ').map(String::toInt)\n a = a.intersect(l2..r2)\n }\n println(a.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1558833524, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Kotlin/s454101822.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s454101822", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toInt)\n val (l, r) = readLine()!!.split(' ').map(String::toInt)\n var a = (l..r).toSet()\n repeat(m - 1) {\n val (l2, r2) = readLine()!!.split(' ').map(String::toInt)\n a = a.intersect(l2..r2)\n }\n println(a.size)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 2115, "memory_kb": 160852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s555010257", "group_id": "codeNet:p03038", "input_text": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun dprint(v: Any?, indent: Int = 0) {\n val indentStr = (1..indent).joinToString(\"\") { \" \" }\n when (v) {\n is Iterable<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is Array<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is IntArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is LongArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is DoubleArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n else -> System.err.println(indentStr + v)\n }\n}\n\nfun > min(a: A, b: A) = if (a < b) a else b\nfun > min(vararg a: A) = a.reduce { acc, x -> min(acc, x) }\nfun > max(a: A, b: A) = if (a > b) a else b\nfun > max(vararg a: A) = a.reduce { acc, x -> max(acc, x) }\n\n////////////////////////////////////////////////////////////////////////\n\n////////////////////////////////////////////////////////////////////////\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n val sc = Scanner(System.`in`)\n// for (t in 1..sc.next().toInt()) {\n Problem.solve(sc, pw)\n// }\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val M = sc.next().toInt()\n val A = Array(N) { sc.next().toLong() }.sorted().toLongArray()\n val BC = Array(M) {\n Pair(sc.next().toInt(), sc.next().toLong())\n }.sortedBy { -it.second }\n var i = 0\n BC.forEach {\n var b = it.first\n val c = it.second\n while (b > 0 && A[i] < c) {\n A[i] = c\n b--\n i++\n }\n }\n pw.println(A.sum())\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1589410467, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s555010257.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s555010257", "user_id": "u297767059"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\n\nclass Scanner(`in`: java.io.InputStream) {\n private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))\n private var tokenizer: StringTokenizer? = null\n\n fun next(): String {\n if (tokenizer?.hasMoreTokens() != true) {\n tokenizer = StringTokenizer(reader.readLine())\n }\n return tokenizer!!.nextToken()\n }\n\n fun nextLine(): String {\n return if (tokenizer?.hasMoreTokens() != true) {\n reader.readLine()\n } else tokenizer!!.nextToken(\"\\n\")\n }\n}\n\nfun dprint(v: Any?, indent: Int = 0) {\n val indentStr = (1..indent).joinToString(\"\") { \" \" }\n when (v) {\n is Iterable<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is Array<*> -> {\n System.err.println(\"$indentStr[\")\n v.forEach { dprint(it, indent + 1) }\n System.err.println(\"$indentStr]\")\n }\n is IntArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is LongArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n is DoubleArray -> System.err.println(indentStr + \"[\" + v.joinToString(\",\") + \"]\")\n else -> System.err.println(indentStr + v)\n }\n}\n\nfun > min(a: A, b: A) = if (a < b) a else b\nfun > min(vararg a: A) = a.reduce { acc, x -> min(acc, x) }\nfun > max(a: A, b: A) = if (a > b) a else b\nfun > max(vararg a: A) = a.reduce { acc, x -> max(acc, x) }\n\n////////////////////////////////////////////////////////////////////////\n\n////////////////////////////////////////////////////////////////////////\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n val sc = Scanner(System.`in`)\n// for (t in 1..sc.next().toInt()) {\n Problem.solve(sc, pw)\n// }\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val M = sc.next().toInt()\n val A = Array(N) { sc.next().toLong() }.sorted().toLongArray()\n val BC = Array(M) {\n Pair(sc.next().toInt(), sc.next().toLong())\n }.sortedBy { -it.second }\n var i = 0\n BC.forEach {\n var b = it.first\n val c = it.second\n while (b > 0 && A[i] < c) {\n A[i] = c\n b--\n i++\n }\n }\n pw.println(A.sum())\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2567, "cpu_time_ms": 1331, "memory_kb": 82776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s148285560", "group_id": "codeNet:p03038", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map{it.toInt()}\n val A = readLine()!!.split(\" \").map{it.toLong()}\n val p = TreeMap()\n\n for (i in 1..M) {\n val (b, c) = readLine()!!.split(\" \").map{it.toInt()}\n p[c.toLong()] = (p[c.toLong()] ?: 0L) + b\n }\n for (i in A.indices) {\n p[A[i]] = (p[A[i]] ?: 0L) + 1\n }\n\n var res = 0L\n var cnt = 0L\n while (cnt < N) {\n val e = p.pollLastEntry()\n val num = Math.min(N - cnt, e.value)\n res += e.key * num\n cnt += num\n }\n\n println(res)\n}\n", "language": "Kotlin", "metadata": {"date": 1575849100, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s148285560.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s148285560", "user_id": "u183530284"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map{it.toInt()}\n val A = readLine()!!.split(\" \").map{it.toLong()}\n val p = TreeMap()\n\n for (i in 1..M) {\n val (b, c) = readLine()!!.split(\" \").map{it.toInt()}\n p[c.toLong()] = (p[c.toLong()] ?: 0L) + b\n }\n for (i in A.indices) {\n p[A[i]] = (p[A[i]] ?: 0L) + 1\n }\n\n var res = 0L\n var cnt = 0L\n while (cnt < N) {\n val e = p.pollLastEntry()\n val num = Math.min(N - cnt, e.value)\n res += e.key * num\n cnt += num\n }\n\n println(res)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 956, "memory_kb": 85224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s627058456", "group_id": "codeNet:p03038", "input_text": "fun main(args: Array) {\n abc127d()\n}\n\nprivate data class Operation(val amount: Int, val value: Long)\n\n// 愚直に\nfun abc127d() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = readLine()!!.split(\" \").map { it.toLong() }.toLongArray()\n val bcList = (1..m).map { readLine()!!.split(\" \").map { it.toLong() } }\n .map { Operation(it[0].toInt(), it[1]) }\n\n var sortedList = aList.sortedArray()\n bcList.forEach { operation ->\n sortedList = (sortedList.take(operation.amount).map { Math.max(it, operation.value) } +\n sortedList.drop(operation.amount)).toLongArray().sortedArray()\n }\n\n val answer = sortedList.sum()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1569794760, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s627058456.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s627058456", "user_id": "u139478771"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main(args: Array) {\n abc127d()\n}\n\nprivate data class Operation(val amount: Int, val value: Long)\n\n// 愚直に\nfun abc127d() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = readLine()!!.split(\" \").map { it.toLong() }.toLongArray()\n val bcList = (1..m).map { readLine()!!.split(\" \").map { it.toLong() } }\n .map { Operation(it[0].toInt(), it[1]) }\n\n var sortedList = aList.sortedArray()\n bcList.forEach { operation ->\n sortedList = (sortedList.take(operation.amount).map { Math.max(it, operation.value) } +\n sortedList.drop(operation.amount)).toLongArray().sortedArray()\n }\n\n val answer = sortedList.sum()\n\n println(answer)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 716, "cpu_time_ms": 2111, "memory_kb": 147584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s451665649", "group_id": "codeNet:p03038", "input_text": "fun main(args:Array) {\n val (N,M) = readLine()!!.split(\" \").map(String::toInt)\n val a_integers = readLine()!!.split(\" \").map(String::toLong)\n \n val b_c = (1..M).map {\n val (b,c) = readLine()!!.split(\" \").map(String::toLong)\n Pair(b.toInt(),c)\n }.sortedByDescending {it.second} \n\n val result_list = mutableListOf()\n\n outer@ for ((b,c) in b_c) {\n for (i in (1..b)) {\n result_list.add(c)\n if(result_list.size >= N) {\n break@outer\n }\n }\n }\n result_list.addAll(a_integers)\n result_list.sortedDescending().take(N).fold(0L) {sum,ele-> sum+ele}.run(::println)\n}", "language": "Kotlin", "metadata": {"date": 1558844814, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s451665649.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s451665649", "user_id": "u181807786"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main(args:Array) {\n val (N,M) = readLine()!!.split(\" \").map(String::toInt)\n val a_integers = readLine()!!.split(\" \").map(String::toLong)\n \n val b_c = (1..M).map {\n val (b,c) = readLine()!!.split(\" \").map(String::toLong)\n Pair(b.toInt(),c)\n }.sortedByDescending {it.second} \n\n val result_list = mutableListOf()\n\n outer@ for ((b,c) in b_c) {\n for (i in (1..b)) {\n result_list.add(c)\n if(result_list.size >= N) {\n break@outer\n }\n }\n }\n result_list.addAll(a_integers)\n result_list.sortedDescending().take(N).fold(0L) {sum,ele-> sum+ele}.run(::println)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 670, "cpu_time_ms": 1186, "memory_kb": 108316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s531164098", "group_id": "codeNet:p03038", "input_text": "fun main(args: Array) {\n val (N,M) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toLong() }.sorted().toLongArray()\n val BC = Array(M){ readLine()!!.split(\" \").map { it->it.toLong() }}.sortedBy { -it[1] }\n\n var cursor=0\n var sum = 0.toLong()\n BC.forEach {\n if(cursor=N)break\n sum+=Math.max(A[cursor+i],it[1])\n }\n cursor+=it[0].toInt()\n }\n }\n for (i in cursor until N){\n sum+=A[i]\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1558836335, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03038/input.txt", "sample_output_relpath": "derived/input_output/data/p03038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03038/Kotlin/s531164098.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s531164098", "user_id": "u586526576"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "fun main(args: Array) {\n val (N,M) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toLong() }.sorted().toLongArray()\n val BC = Array(M){ readLine()!!.split(\" \").map { it->it.toLong() }}.sortedBy { -it[1] }\n\n var cursor=0\n var sum = 0.toLong()\n BC.forEach {\n if(cursor=N)break\n sum+=Math.max(A[cursor+i],it[1])\n }\n cursor+=it[0].toInt()\n }\n }\n for (i in cursor until N){\n sum+=A[i]\n }\n println(sum)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 613, "cpu_time_ms": 1530, "memory_kb": 95120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s094990054", "group_id": "codeNet:p03041", "input_text": "import kotlin.comparisons.*\nimport java.util.*\n\nconst val MOD = 1000000007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\nfun main(args: Array) {\n val (n, k) = readIs()\n val s = readLine()!!.toCharArray()\n s[k - 1] = s[k - 1].toLowerCase()\n println(s.joinToString(\"\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1592154681, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/Kotlin/s094990054.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s094990054", "user_id": "u051841332"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "import kotlin.comparisons.*\nimport java.util.*\n\nconst val MOD = 1000000007L\n\nfun readI() = readLine()!!.toInt()\nfun readL() = readLine()!!.toLong()\nfun readD() = readLine()!!.toDouble()\nfun readIs() = readLine()!!.split(' ').map(String::toInt)\nfun readLs() = readLine()!!.split(' ').map(String::toLong)\nfun readDs() = readLine()!!.split(' ').map(String::toDouble)\n\nfun main(args: Array) {\n val (n, k) = readIs()\n val s = readLine()!!.toCharArray()\n s[k - 1] = s[k - 1].toLowerCase()\n println(s.joinToString(\"\"))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 526, "cpu_time_ms": 241, "memory_kb": 37916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s827723369", "group_id": "codeNet:p03041", "input_text": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\nfun println(value: Any) { pw.println(value) }\n\n//ABC129x_x\nfun func() {\n val (N, K) = listOfInt()\n var C = next().substring(0, N).toCharArray()\n C[K-1] = C[K-1].toLowerCase()\n println(\"${C.joinToString(separator = \"\")}\")\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) } //{ it.toInt() }\n", "language": "Kotlin", "metadata": {"date": 1560119762, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/Kotlin/s827723369.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s827723369", "user_id": "u043150661"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "import java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nfun main(args: Array) {\n func()\n pw.flush()\n}\nfun println(value: Any) { pw.println(value) }\n\n//ABC129x_x\nfun func() {\n val (N, K) = listOfInt()\n var C = next().substring(0, N).toCharArray()\n C[K-1] = C[K-1].toLowerCase()\n println(\"${C.joinToString(separator = \"\")}\")\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) } //{ it.toInt() }\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 501, "cpu_time_ms": 235, "memory_kb": 35948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s638563161", "group_id": "codeNet:p03042", "input_text": "fun main(args: Array) {\n\n val s = readLine()!!.split(\"\").toTypedArray()\n\n val mm = listOf(\"01\", \"02\", \"03\", \"04\", \"05\", \"06\", \"07\", \"08\", \"09\", \"10\", \"11\", \"12\")\n val yy = (1..99).map { if (it in (1..9)) \"0$it\" else it.toString() }\n\n val l = (s[1] + s[2])\n val r = (s[3] + s[4])\n\n // 左がMMかつ右がYYの場合\n if (l in mm && r in yy) {\n // 左がYYかつ右がMMの場合\n if (l in yy && r in mm) {\n println(\"AMBIGUOUS\")\n return\n }\n\n println(\"MMYY\")\n return\n }\n\n // 左がYYかつ右がMMの場合\n if (l in yy && r in mm) {\n //左がMMかつ右がYYの場合\n if (l in mm && r in yy) {\n println(\"AMBIGUOUS\")\n return\n }\n\n println(\"YYMM\")\n return\n }\n\n println(\"NA\")\n}", "language": "Kotlin", "metadata": {"date": 1558318025, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03042/input.txt", "sample_output_relpath": "derived/input_output/data/p03042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03042/Kotlin/s638563161.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s638563161", "user_id": "u108272327"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "fun main(args: Array) {\n\n val s = readLine()!!.split(\"\").toTypedArray()\n\n val mm = listOf(\"01\", \"02\", \"03\", \"04\", \"05\", \"06\", \"07\", \"08\", \"09\", \"10\", \"11\", \"12\")\n val yy = (1..99).map { if (it in (1..9)) \"0$it\" else it.toString() }\n\n val l = (s[1] + s[2])\n val r = (s[3] + s[4])\n\n // 左がMMかつ右がYYの場合\n if (l in mm && r in yy) {\n // 左がYYかつ右がMMの場合\n if (l in yy && r in mm) {\n println(\"AMBIGUOUS\")\n return\n }\n\n println(\"MMYY\")\n return\n }\n\n // 左がYYかつ右がMMの場合\n if (l in yy && r in mm) {\n //左がMMかつ右がYYの場合\n if (l in mm && r in yy) {\n println(\"AMBIGUOUS\")\n return\n }\n\n println(\"YYMM\")\n return\n }\n\n println(\"NA\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 831, "cpu_time_ms": 247, "memory_kb": 37852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s387559442", "group_id": "codeNet:p03042", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val s = scanner.next()\n val head = s.substring(0..1).toInt()\n val tail = s.substring(2..3).toInt()\n if (canY(head) && canM(tail)) {\n if (canM(head) && canY(tail)) {\n print(\"AMBIGUOUS\")\n } else {\n print(\"YYMM\")\n }\n } else {\n if (canM(head) && canY(tail)) {\n print(\"MMYY\")\n } else {\n print(\"NA\")\n }\n }\n}\n\nfun canY(i: Int): Boolean {\n return i in 0..99\n}\n\nfun canM(i: Int): Boolean {\n return i in 1..12\n}", "language": "Kotlin", "metadata": {"date": 1558315923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03042/input.txt", "sample_output_relpath": "derived/input_output/data/p03042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03042/Kotlin/s387559442.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s387559442", "user_id": "u111718424"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val s = scanner.next()\n val head = s.substring(0..1).toInt()\n val tail = s.substring(2..3).toInt()\n if (canY(head) && canM(tail)) {\n if (canM(head) && canY(tail)) {\n print(\"AMBIGUOUS\")\n } else {\n print(\"YYMM\")\n }\n } else {\n if (canM(head) && canY(tail)) {\n print(\"MMYY\")\n } else {\n print(\"NA\")\n }\n }\n}\n\nfun canY(i: Int): Boolean {\n return i in 0..99\n}\n\nfun canM(i: Int): Boolean {\n return i in 1..12\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 603, "cpu_time_ms": 201, "memory_kb": 31392}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s740110372", "group_id": "codeNet:p03043", "input_text": "//import java.math.BigDecimal\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n\n val counts = (1..n).map { reqFace(it, k) }\n val maxCount = counts.max()!!\n val sum = counts.map { Math.pow(2.0, (maxCount - it).toDouble()) }.sum()\n print(sum / (n * (Math.pow(2.0, maxCount.toDouble()))))\n// val sum = counts.map { BigDecimal(2).pow(maxCount - it) }.sumBy { it.toInt() }\n// val ans = BigDecimal(sum).divide(BigDecimal(n).multiply(BigDecimal(2).pow(maxCount)))\n// print(ans.toPlainString())\n}\n\nfun reqFace(base: Int, req: Int): Int {\n if (base >= req) return 0\n\n var count = 1\n var score = base\n while (score * 2 < req) {\n score *= 2\n count++\n }\n return count\n}", "language": "Kotlin", "metadata": {"date": 1558318991, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03043.html", "problem_id": "p03043", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03043/input.txt", "sample_output_relpath": "derived/input_output/data/p03043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03043/Kotlin/s740110372.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s740110372", "user_id": "u111718424"}, "prompt_components": {"gold_output": "0.145833333333\n", "input_to_evaluate": "//import java.math.BigDecimal\nimport java.util.*\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val k = scanner.nextInt()\n\n val counts = (1..n).map { reqFace(it, k) }\n val maxCount = counts.max()!!\n val sum = counts.map { Math.pow(2.0, (maxCount - it).toDouble()) }.sum()\n print(sum / (n * (Math.pow(2.0, maxCount.toDouble()))))\n// val sum = counts.map { BigDecimal(2).pow(maxCount - it) }.sumBy { it.toInt() }\n// val ans = BigDecimal(sum).divide(BigDecimal(n).multiply(BigDecimal(2).pow(maxCount)))\n// print(ans.toPlainString())\n}\n\nfun reqFace(base: Int, req: Int): Int {\n if (base >= req) return 0\n\n var count = 1\n var score = base\n while (score * 2 < req) {\n score *= 2\n count++\n }\n return count\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "sample_input": "3 10\n"}, "reference_outputs": ["0.145833333333\n"], "source_document_id": "p03043", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 812, "cpu_time_ms": 262, "memory_kb": 42416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s057967438", "group_id": "codeNet:p03045", "input_text": "\ntypealias Graph = MutableList>\nfun create_empty_graph(n:Int):Graph{\n return MutableList(n) {_ -> mutableListOf()}\n}\nfun main(args:Array) {\n val (n,m) = readLine()!!.split(\" \").map(String::toInt)\n var g = create_empty_graph(n)\n for (_i in 0 until m) {\n var (x,y,_) = readLine()!!.split(\" \").map(String::toInt)\n x--\n y--\n g[x].add(y)\n g[y].add(x)\n }\n\n var used = MutableList(n) {_ -> false}\n var cnt = 0\n for (i in 0 until n) {\n if(used[i]) continue\n var stack = mutableListOf()\n cnt++\n used[i] = true\n stack.add(i)\n while(!stack.isEmpty()){\n val v = stack.lastOrNull()!!\n stack.removeAt(stack.size-1)\n for(to in g[v]) {\n if(!used[to]) {\n used[to] = true\n stack.add(to)\n }\n }\n }\n }\n\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1594491156, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03045.html", "problem_id": "p03045", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03045/input.txt", "sample_output_relpath": "derived/input_output/data/p03045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03045/Kotlin/s057967438.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s057967438", "user_id": "u283229916"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\ntypealias Graph = MutableList>\nfun create_empty_graph(n:Int):Graph{\n return MutableList(n) {_ -> mutableListOf()}\n}\nfun main(args:Array) {\n val (n,m) = readLine()!!.split(\" \").map(String::toInt)\n var g = create_empty_graph(n)\n for (_i in 0 until m) {\n var (x,y,_) = readLine()!!.split(\" \").map(String::toInt)\n x--\n y--\n g[x].add(y)\n g[y].add(x)\n }\n\n var used = MutableList(n) {_ -> false}\n var cnt = 0\n for (i in 0 until n) {\n if(used[i]) continue\n var stack = mutableListOf()\n cnt++\n used[i] = true\n stack.add(i)\n while(!stack.isEmpty()){\n val v = stack.lastOrNull()!!\n stack.removeAt(stack.size-1)\n for(to in g[v]) {\n if(!used[to]) {\n used[to] = true\n stack.add(to)\n }\n }\n }\n }\n\n println(cnt)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "sample_input": "3 1\n1 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03045", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 959, "cpu_time_ms": 696, "memory_kb": 74992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s425513163", "group_id": "codeNet:p03045", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toLong)\n val union = UnionFind(n.toInt())\n for (i in 1..m) {\n val (x, y, z) = readLine()!!.split(' ').map(String::toInt)\n union.union(x - 1, y - 1)\n }\n println(union.count())\n}\n\nclass UnionFind(private var num: Int) {\n private val parent: IntArray = IntArray(num)\n private val rank: IntArray = IntArray(num)\n private val size: IntArray = IntArray(num)\n\n init {\n for (i in 0 until num) {\n parent[i] = i\n rank[i] = 1\n size[i] = 1\n }\n }\n\n fun union(u: Int, v: Int): Int {\n var u = u\n var v = v\n u = root(u)\n v = root(v)\n if (u == v)\n return u\n if (rank[v] < rank[u]) {\n val t = v\n v = u\n u = t\n }\n parent[u] = v\n rank[v] += rank[u]\n rank[u] = -1\n num--\n\n return v\n }\n\n fun root(u: Int): Int {\n var u = u\n while (parent[u] != u)\n u = parent[u]\n return u\n }\n\n fun count(): Int {\n return parent.filterIndexed { index, i -> index == i }.size\n }\n}", "language": "Kotlin", "metadata": {"date": 1558316348, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03045.html", "problem_id": "p03045", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03045/input.txt", "sample_output_relpath": "derived/input_output/data/p03045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03045/Kotlin/s425513163.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s425513163", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toLong)\n val union = UnionFind(n.toInt())\n for (i in 1..m) {\n val (x, y, z) = readLine()!!.split(' ').map(String::toInt)\n union.union(x - 1, y - 1)\n }\n println(union.count())\n}\n\nclass UnionFind(private var num: Int) {\n private val parent: IntArray = IntArray(num)\n private val rank: IntArray = IntArray(num)\n private val size: IntArray = IntArray(num)\n\n init {\n for (i in 0 until num) {\n parent[i] = i\n rank[i] = 1\n size[i] = 1\n }\n }\n\n fun union(u: Int, v: Int): Int {\n var u = u\n var v = v\n u = root(u)\n v = root(v)\n if (u == v)\n return u\n if (rank[v] < rank[u]) {\n val t = v\n v = u\n u = t\n }\n parent[u] = v\n rank[v] += rank[u]\n rank[u] = -1\n num--\n\n return v\n }\n\n fun root(u: Int): Int {\n var u = u\n while (parent[u] != u)\n u = parent[u]\n return u\n }\n\n fun count(): Int {\n return parent.filterIndexed { index, i -> index == i }.size\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "sample_input": "3 1\n1 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03045", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1197, "cpu_time_ms": 581, "memory_kb": 58176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s422267682", "group_id": "codeNet:p03048", "input_text": "fun main() {\n val R = Integer.parseInt(readLine())\n val G = Integer.parseInt(readLine())\n val B = Integer.parseInt(readLine())\n val N = Integer.parseInt(readLine())\n\n var ans = 0\n for(i in 0..N step R){\n for(j in 0..N-i step G){\n if((N - i - j) % B == 0)\n ans++\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1557673280, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03048.html", "problem_id": "p03048", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03048/input.txt", "sample_output_relpath": "derived/input_output/data/p03048/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03048/Kotlin/s422267682.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s422267682", "user_id": "u184572586"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val R = Integer.parseInt(readLine())\n val G = Integer.parseInt(readLine())\n val B = Integer.parseInt(readLine())\n val N = Integer.parseInt(readLine())\n\n var ans = 0\n for(i in 0..N step R){\n for(j in 0..N-i step G){\n if((N - i - j) % B == 0)\n ans++\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\nRed boxes, each containing R red balls\n\nGreen boxes, each containing G green balls\n\nBlue boxes, each containing B blue balls\n\nSnuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.\nHow many triples of non-negative integers (r,g,b) achieve this?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq R,G,B,N \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR G B N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 3 4\n\nSample Output 1\n\n4\n\nFour triples achieve the objective, as follows:\n\n(4,0,0)\n\n(2,1,0)\n\n(1,0,1)\n\n(0,2,0)\n\nSample Input 2\n\n13 1 4 3000\n\nSample Output 2\n\n87058", "sample_input": "1 2 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03048", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\nRed boxes, each containing R red balls\n\nGreen boxes, each containing G green balls\n\nBlue boxes, each containing B blue balls\n\nSnuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.\nHow many triples of non-negative integers (r,g,b) achieve this?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq R,G,B,N \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR G B N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 3 4\n\nSample Output 1\n\n4\n\nFour triples achieve the objective, as follows:\n\n(4,0,0)\n\n(2,1,0)\n\n(1,0,1)\n\n(0,2,0)\n\nSample Input 2\n\n13 1 4 3000\n\nSample Output 2\n\n87058", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 154, "memory_kb": 31268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s040758759", "group_id": "codeNet:p03049", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n\n var bStart = 0\n var aEnd = 0\n var both = 0\n var cnt = 0\n\n val regex = \"(AB)\".toRegex()\n\n repeat(n) {\n val s = readLine()!!\n cnt += regex.findAll(s).count()\n if (s[0] == 'B' && s[s.length-1] == 'A') {\n both++\n } else if (s[0] == 'B') {\n bStart++\n } else if (s[s.length-1] == 'A') {\n aEnd++\n }\n }\n\n if (both == 0) {\n cnt += Math.min(bStart, aEnd)\n } else {\n if (bStart + aEnd > 0) {\n cnt += Math.min(bStart, aEnd) + both\n } else {\n cnt += Math.max(both - 1, 0)\n }\n }\n\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1582377368, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03049/input.txt", "sample_output_relpath": "derived/input_output/data/p03049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03049/Kotlin/s040758759.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s040758759", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n\n var bStart = 0\n var aEnd = 0\n var both = 0\n var cnt = 0\n\n val regex = \"(AB)\".toRegex()\n\n repeat(n) {\n val s = readLine()!!\n cnt += regex.findAll(s).count()\n if (s[0] == 'B' && s[s.length-1] == 'A') {\n both++\n } else if (s[0] == 'B') {\n bStart++\n } else if (s[s.length-1] == 'A') {\n aEnd++\n }\n }\n\n if (both == 0) {\n cnt += Math.min(bStart, aEnd)\n } else {\n if (bStart + aEnd > 0) {\n cnt += Math.min(bStart, aEnd) + both\n } else {\n cnt += Math.max(both - 1, 0)\n }\n }\n\n println(cnt)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 707, "cpu_time_ms": 349, "memory_kb": 39884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s943703202", "group_id": "codeNet:p03050", "input_text": "fun main(args: Array) {\n val N=readLine()!!.toLong()\n val sq = Math.sqrt(N.toDouble()).toLong()\n var sum = 0.toLong()\n for(i in 1 .. sq){\n if(N%i==0L){\n if(N/i-1>i){\n sum+=N/i-1\n }\n }\n }\n print(sum)\n}", "language": "Kotlin", "metadata": {"date": 1557627714, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03050.html", "problem_id": "p03050", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03050/input.txt", "sample_output_relpath": "derived/input_output/data/p03050/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03050/Kotlin/s943703202.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s943703202", "user_id": "u586526576"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val N=readLine()!!.toLong()\n val sq = Math.sqrt(N.toDouble()).toLong()\n var sum = 0.toLong()\n for(i in 1 .. sq){\n if(N%i==0L){\n if(N/i-1>i){\n sum+=N/i-1\n }\n }\n }\n print(sum)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "sample_input": "8\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03050", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 237, "memory_kb": 31836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s287487564", "group_id": "codeNet:p03054", "input_text": "private data class Dist(var r: Int, var l: Int, var u: Int, var d: Int)\n\nfun main(args: Array) {\n val (h, w, n) = readLine()!!.split(\" \").map { it.toInt() }\n val (sr, sc) = readLine()!!.split(\" \").map { it.toInt() }\n\n val S = readLine()!!.toCharArray().toMutableList()\n val T = readLine()!!.toCharArray().toMutableList()\n\n val Sdist = Dist(0,0,0,0)\n val Tdist = Dist(0,0,0,0)\n\n val initialDist = Dist(l = sc - 1, r = w - sc, u = sr - 1, d = h - sr)\n\n fun addDist(dist:Dist, c: Char){\n if (c==\"L\".single()){\n dist.l +=1\n }\n if (c==\"R\".single()){\n dist.r +=1\n }\n if (c==\"U\".single()){\n dist.u +=1\n }\n if (c==\"D\".single()){\n dist.d +=1\n }\n }\n\n\n for (i in 0 until n ){\n val s = S[i]\n addDist(Sdist, s)\n\n if (initialDist.r - (Sdist.r - Tdist.l) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.l - (Sdist.l - Tdist.r) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.u - (Sdist.u - Tdist.d) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.d - (Sdist.d - Tdist.u) < 0 ){\n print(\"NO\")\n return\n }\n\n val t = T[i]\n addDist(Tdist, t)\n\n if (initialDist.r - (Sdist.r - Tdist.l) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.l - (Sdist.l - Tdist.r) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.u - (Sdist.u - Tdist.d) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.d - (Sdist.d - Tdist.u) < 0 ){\n print(\"NO\")\n return\n }\n }\n print(\"YES\")\n}\n\n", "language": "Kotlin", "metadata": {"date": 1557026981, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03054.html", "problem_id": "p03054", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03054/input.txt", "sample_output_relpath": "derived/input_output/data/p03054/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03054/Kotlin/s287487564.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s287487564", "user_id": "u889750959"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "private data class Dist(var r: Int, var l: Int, var u: Int, var d: Int)\n\nfun main(args: Array) {\n val (h, w, n) = readLine()!!.split(\" \").map { it.toInt() }\n val (sr, sc) = readLine()!!.split(\" \").map { it.toInt() }\n\n val S = readLine()!!.toCharArray().toMutableList()\n val T = readLine()!!.toCharArray().toMutableList()\n\n val Sdist = Dist(0,0,0,0)\n val Tdist = Dist(0,0,0,0)\n\n val initialDist = Dist(l = sc - 1, r = w - sc, u = sr - 1, d = h - sr)\n\n fun addDist(dist:Dist, c: Char){\n if (c==\"L\".single()){\n dist.l +=1\n }\n if (c==\"R\".single()){\n dist.r +=1\n }\n if (c==\"U\".single()){\n dist.u +=1\n }\n if (c==\"D\".single()){\n dist.d +=1\n }\n }\n\n\n for (i in 0 until n ){\n val s = S[i]\n addDist(Sdist, s)\n\n if (initialDist.r - (Sdist.r - Tdist.l) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.l - (Sdist.l - Tdist.r) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.u - (Sdist.u - Tdist.d) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.d - (Sdist.d - Tdist.u) < 0 ){\n print(\"NO\")\n return\n }\n\n val t = T[i]\n addDist(Tdist, t)\n\n if (initialDist.r - (Sdist.r - Tdist.l) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.l - (Sdist.l - Tdist.r) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.u - (Sdist.u - Tdist.d) < 0 ){\n print(\"NO\")\n return\n }\n\n if (initialDist.d - (Sdist.d - Tdist.u) < 0 ){\n print(\"NO\")\n return\n }\n }\n print(\"YES\")\n}\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\nOn this grid, there is a piece, which is initially placed at square (s_r,s_c).\n\nTakahashi and Aoki will play a game, where each player has a string of length N.\nTakahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: L, R, U and D.\n\nThe game consists of N steps. The i-th step proceeds as follows:\n\nFirst, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece.\n\nSecond, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece.\n\nHere, to move the piece in the direction of L, R, U and D, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done.\n\nTakahashi wants to remove the piece from the grid in one of the N steps.\nAoki, on the other hand, wants to finish the N steps with the piece remaining on the grid.\nDetermine if the piece will remain on the grid at the end of the game when both players play optimally.\n\nConstraints\n\n2 \\leq H,W \\leq 2 \\times 10^5\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq s_r \\leq H\n\n1 \\leq s_c \\leq W\n\n|S|=|T|=N\n\nS and T consists of the four kinds of letters L, R, U and D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\ns_r s_c\nS\nT\n\nOutput\n\nIf the piece will remain on the grid at the end of the game, print YES; otherwise, print NO.\n\nSample Input 1\n\n2 3 3\n2 2\nRRL\nLUD\n\nSample Output 1\n\nYES\n\nHere is one possible progress of the game:\n\nTakahashi moves the piece right. The piece is now at (2,3).\n\nAoki moves the piece left. The piece is now at (2,2).\n\nTakahashi does not move the piece. The piece remains at (2,2).\n\nAoki moves the piece up. The piece is now at (1,2).\n\nTakahashi moves the piece left. The piece is now at (1,1).\n\nAoki does not move the piece. The piece remains at (1,1).\n\nSample Input 2\n\n4 3 5\n2 2\nUDRRR\nLLDUD\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n5 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD\n\nSample Output 3\n\nNO", "sample_input": "2 3 3\n2 2\nRRL\nLUD\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03054", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\nOn this grid, there is a piece, which is initially placed at square (s_r,s_c).\n\nTakahashi and Aoki will play a game, where each player has a string of length N.\nTakahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: L, R, U and D.\n\nThe game consists of N steps. The i-th step proceeds as follows:\n\nFirst, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece.\n\nSecond, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece.\n\nHere, to move the piece in the direction of L, R, U and D, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done.\n\nTakahashi wants to remove the piece from the grid in one of the N steps.\nAoki, on the other hand, wants to finish the N steps with the piece remaining on the grid.\nDetermine if the piece will remain on the grid at the end of the game when both players play optimally.\n\nConstraints\n\n2 \\leq H,W \\leq 2 \\times 10^5\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq s_r \\leq H\n\n1 \\leq s_c \\leq W\n\n|S|=|T|=N\n\nS and T consists of the four kinds of letters L, R, U and D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\ns_r s_c\nS\nT\n\nOutput\n\nIf the piece will remain on the grid at the end of the game, print YES; otherwise, print NO.\n\nSample Input 1\n\n2 3 3\n2 2\nRRL\nLUD\n\nSample Output 1\n\nYES\n\nHere is one possible progress of the game:\n\nTakahashi moves the piece right. The piece is now at (2,3).\n\nAoki moves the piece left. The piece is now at (2,2).\n\nTakahashi does not move the piece. The piece remains at (2,2).\n\nAoki moves the piece up. The piece is now at (1,2).\n\nTakahashi moves the piece left. The piece is now at (1,1).\n\nAoki does not move the piece. The piece remains at (1,1).\n\nSample Input 2\n\n4 3 5\n2 2\nUDRRR\nLLDUD\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n5 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1796, "cpu_time_ms": 410, "memory_kb": 41928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s675428396", "group_id": "codeNet:p03059", "input_text": "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 t = sc.nextInt()\n println(problem125a(a, b, t))\n}\n\nfun problem125a(a: Int, b: Int, t: Int): Int {\n return b * (t / a)\n}", "language": "Kotlin", "metadata": {"date": 1591919509, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03059/input.txt", "sample_output_relpath": "derived/input_output/data/p03059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03059/Kotlin/s675428396.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s675428396", "user_id": "u073232808"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "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 t = sc.nextInt()\n println(problem125a(a, b, t))\n}\n\nfun problem125a(a: Int, b: Int, t: Int): Int {\n return b * (t / a)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 187, "memory_kb": 31256}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s281175609", "group_id": "codeNet:p03059", "input_text": "fun main(args: Array) {\n val (sec, bisCount, limitTmp) = readLine()!!.split(\" \").map { it.toInt() }\n\n val limit = limitTmp + 0.5\n\n val count = Math.floor(limit / sec)\n\n print((count * bisCount).toInt())\n}\n", "language": "Kotlin", "metadata": {"date": 1556413661, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03059/input.txt", "sample_output_relpath": "derived/input_output/data/p03059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03059/Kotlin/s281175609.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s281175609", "user_id": "u249910602"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args: Array) {\n val (sec, bisCount, limitTmp) = readLine()!!.split(\" \").map { it.toInt() }\n\n val limit = limitTmp + 0.5\n\n val count = Math.floor(limit / sec)\n\n print((count * bisCount).toInt())\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 225, "cpu_time_ms": 244, "memory_kb": 37616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s183466859", "group_id": "codeNet:p03062", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n println(problem125d(n, a))\n}\n\nfun problem125d(n: Int, a: List): Long {\n if (a.contains(0)) return a.map { Math.abs(it) }.sum()\n if (a.count { it < 0L } % 2 == 0) {\n return a.map { Math.abs(it) }.sum()\n }\n val minInt = a.filter { it >= 0L }.min() ?: Math.abs(a.max()!!)\n val min = a.min()!!\n if (Math.abs(min) < minInt) {\n return a.sum()\n }\n return a.map { Math.abs(it) }.sum() - (minInt * 2)\n}", "language": "Kotlin", "metadata": {"date": 1590966299, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Kotlin/s183466859.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s183466859", "user_id": "u073232808"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n println(problem125d(n, a))\n}\n\nfun problem125d(n: Int, a: List): Long {\n if (a.contains(0)) return a.map { Math.abs(it) }.sum()\n if (a.count { it < 0L } % 2 == 0) {\n return a.map { Math.abs(it) }.sum()\n }\n val minInt = a.filter { it >= 0L }.min() ?: Math.abs(a.max()!!)\n val min = a.min()!!\n if (Math.abs(min) < minInt) {\n return a.sum()\n }\n return a.map { Math.abs(it) }.sum() - (minInt * 2)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 603, "cpu_time_ms": 711, "memory_kb": 56452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s001322936", "group_id": "codeNet:p03062", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextLongList()\n val B = A.map { Math.abs(it) }\n val minus = A.count { it < 0 }\n if (minus % 2 == 0) {\n println(B.sum())\n } else {\n val min = B.min()!!\n println(B.sum() - min * 2)\n }\n}", "language": "Kotlin", "metadata": {"date": 1590904866, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Kotlin/s001322936.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s001322936", "user_id": "u860789370"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val N = nextInt()\n val A = nextLongList()\n val B = A.map { Math.abs(it) }\n val minus = A.count { it < 0 }\n if (minus % 2 == 0) {\n println(B.sum())\n } else {\n val min = B.min()!!\n println(B.sum() - min * 2)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 788, "cpu_time_ms": 533, "memory_kb": 61648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s930014176", "group_id": "codeNet:p03063", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val input = readLine()!!\n val count = IntArray(n + 1)\n for (i in 1..n) {\n if (input[i - 1] == '#') {\n count[i] = count[i - 1] + 1\n } else {\n count[i] = count[i - 1]\n }\n }\n val ans = (0..n).map {\n val cost1 = count[it]\n val cost2 = (n - it) - (count[n] - count[it])\n cost1 + cost2 }\n .min()\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1555808868, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03063.html", "problem_id": "p03063", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03063/input.txt", "sample_output_relpath": "derived/input_output/data/p03063/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03063/Kotlin/s930014176.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930014176", "user_id": "u771276542"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val input = readLine()!!\n val count = IntArray(n + 1)\n for (i in 1..n) {\n if (input[i - 1] == '#') {\n count[i] = count[i - 1] + 1\n } else {\n count[i] = count[i - 1]\n }\n }\n val ans = (0..n).map {\n val cost1 = count[it]\n val cost2 = (n - it) - (count[n] - count[it])\n cost1 + cost2 }\n .min()\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03063", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 409, "cpu_time_ms": 315, "memory_kb": 39328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s892336613", "group_id": "codeNet:p03067", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val a = nextLong()\n val b = nextLong()\n val c = nextLong()\n val start = min(a, c)\n val end = max(a, c)\n\n println(if(b in start..end) \"No\" else \"Yes\")\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1588626588, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03067.html", "problem_id": "p03067", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03067/input.txt", "sample_output_relpath": "derived/input_output/data/p03067/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03067/Kotlin/s892336613.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s892336613", "user_id": "u581625805"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val a = nextLong()\n val b = nextLong()\n val c = nextLong()\n val start = min(a, c)\n val end = max(a, c)\n\n println(if(b in start..end) \"No\" else \"Yes\")\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "sample_input": "3 8 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03067", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14326, "cpu_time_ms": 209, "memory_kb": 33952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285837602", "group_id": "codeNet:p03069", "input_text": "fun main(args: Array) {\n tenka12019beginnerc()\n}\n\nfun tenka12019beginnerc() {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n var right = s.lastIndex\n while (right > 0 && s[right] == '#') right--\n\n val slice = s.slice(0..right)\n\n val count = slice.count { it == '.' }\n\n val answer = Math.min(count, slice.length - count)\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1574308654, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03069/input.txt", "sample_output_relpath": "derived/input_output/data/p03069/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03069/Kotlin/s285837602.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s285837602", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n tenka12019beginnerc()\n}\n\nfun tenka12019beginnerc() {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n var right = s.lastIndex\n while (right > 0 && s[right] == '#') right--\n\n val slice = s.slice(0..right)\n\n val count = slice.count { it == '.' }\n\n val answer = Math.min(count, slice.length - count)\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 382, "cpu_time_ms": 247, "memory_kb": 34588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s423486625", "group_id": "codeNet:p03069", "input_text": "fun main(args: Array) {\n\tval n = (readLine() ?: return).toInt()\n\tval s = (readLine() ?: return).toCharArray()\n\tvar white = 0\n\tfor (i in s.indices) if (s[i] == '.') white++\n\tvar min = if (white > s.size) s.size - white else white\n\tvar black = 0\n\tfor (i in s.indices) {\n\t\tif (s[i] == '#') black++\n\t\telse if (s[i] == '.') {\n\t\t\twhite--\n\t\t\tmin = Math.min(min, black + white)\n\t\t}\n\t}\n\tprint(min)\n}", "language": "Kotlin", "metadata": {"date": 1555815751, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03069/input.txt", "sample_output_relpath": "derived/input_output/data/p03069/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03069/Kotlin/s423486625.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s423486625", "user_id": "u801173061"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n\tval n = (readLine() ?: return).toInt()\n\tval s = (readLine() ?: return).toCharArray()\n\tvar white = 0\n\tfor (i in s.indices) if (s[i] == '.') white++\n\tvar min = if (white > s.size) s.size - white else white\n\tvar black = 0\n\tfor (i in s.indices) {\n\t\tif (s[i] == '#') black++\n\t\telse if (s[i] == '.') {\n\t\t\twhite--\n\t\t\tmin = Math.min(min, black + white)\n\t\t}\n\t}\n\tprint(min)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 398, "cpu_time_ms": 276, "memory_kb": 37220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s286194582", "group_id": "codeNet:p03071", "input_text": "fun main() {\n val lines = readLine()!!.split(\" \").map {it.toInt()}\n\n val res1 = lines[0] * 2 - 1\n val res2 = lines[0] + lines[1]\n val res3 = lines[1] * 2 - 1\n\n print(arrayListOf(res1, res2, res3).max())\n}", "language": "Kotlin", "metadata": {"date": 1555182592, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03071/input.txt", "sample_output_relpath": "derived/input_output/data/p03071/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03071/Kotlin/s286194582.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s286194582", "user_id": "u249910602"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main() {\n val lines = readLine()!!.split(\" \").map {it.toInt()}\n\n val res1 = lines[0] * 2 - 1\n val res2 = lines[0] + lines[1]\n val res3 = lines[1] * 2 - 1\n\n print(arrayListOf(res1, res2, res3).max())\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 171, "memory_kb": 29348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s626882372", "group_id": "codeNet:p03072", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval n = readInt()\n\tval h = readListOfInt()\n\n\tvar count = 0\n\tfor(i in 0 until n) {\n\t\tvar isAble = true\n\t\tfor(j in 0 until i) {\n\t\t\tif(h[i] < h[j]) {\n\t\t\t\tisAble = false\n\t\t\t}\n\t\t}\n\t\tif(isAble) count++\n\t}\n\tprintln(count)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "language": "Kotlin", "metadata": {"date": 1573425016, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/Kotlin/s626882372.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s626882372", "user_id": "u026686258"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nfun main(args: Array) {\n\tval n = readInt()\n\tval h = readListOfInt()\n\n\tvar count = 0\n\tfor(i in 0 until n) {\n\t\tvar isAble = true\n\t\tfor(j in 0 until i) {\n\t\t\tif(h[i] < h[j]) {\n\t\t\t\tisAble = false\n\t\t\t}\n\t\t}\n\t\tif(isAble) count++\n\t}\n\tprintln(count)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\nclass Stack(private var st: MutableList = mutableListOf()) {\n\tfun isEmpty() = st.isEmpty()\n\tfun top(): T = st.last()\n\tfun push(e: T) { st.add(e) }\n\tfun pop() { st = st.dropLast(1).toMutableList() }\n}\n\nclass Queue(private var que: MutableList = mutableListOf()) {\n\tfun isEmpty() = que.isEmpty()\n\tfun top(): T = que.first()\n\tfun push(e: T) { que.add(e) }\n\tfun pop() { que = que.drop(1).toMutableList() }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3850, "cpu_time_ms": 239, "memory_kb": 38028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s456295217", "group_id": "codeNet:p03072", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val h = (0 until n).map { sc.next().toInt() }\n println(problem124a(n, h))\n}\n\nfun problem124a(n: Int, h: List): Int {\n val dp = (0 until n).map { 0 }.toMutableList()\n var count = 1\n dp[0] = h[0]\n for (i in 1 until n) {\n if (dp[i - 1] <= h[i]) count++\n dp[i] = Math.max(dp[i - 1], h[i])\n }\n return count\n}", "language": "Kotlin", "metadata": {"date": 1568988194, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/Kotlin/s456295217.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s456295217", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val h = (0 until n).map { sc.next().toInt() }\n println(problem124a(n, h))\n}\n\nfun problem124a(n: Int, h: List): Int {\n val dp = (0 until n).map { 0 }.toMutableList()\n var count = 1\n dp[0] = h[0]\n for (i in 1 until n) {\n if (dp[i - 1] <= h[i]) count++\n dp[i] = Math.max(dp[i - 1], h[i])\n }\n return count\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 190, "memory_kb": 29480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s690010318", "group_id": "codeNet:p03072", "input_text": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val H = readInts()\n\n var count = 0\n var max = H[0]\n for (h in H) {\n if (max > h) {\n continue\n }\n\n count++\n\n if (max < h) {\n max = h\n }\n }\n\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1555183017, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/Kotlin/s690010318.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s690010318", "user_id": "u963316883"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "private fun readInts() = readLine()!!.split(\" \").map { it.toInt() }\n\nfun main(args: Array) {\n val N = readLine()!!.toInt()\n val H = readInts()\n\n var count = 0\n var max = H[0]\n for (h in H) {\n if (max > h) {\n continue\n }\n\n count++\n\n if (max < h) {\n max = h\n }\n }\n\n println(count)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 238, "memory_kb": 36108}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s605387421", "group_id": "codeNet:p03073", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n println(Math.min(f(s), f(s.reversed())))\n}\n\nprivate fun f(s: String): Int {\n if (s.length == 1) {\n return 0\n }\n\n var c = s[0]\n\n return s.substring(1).map {\n if (c == it) {\n c = if (c == '0') '1' else '0'\n 1\n } else {\n c = it\n 0\n }\n }.sum()\n}", "language": "Kotlin", "metadata": {"date": 1555183207, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03073/input.txt", "sample_output_relpath": "derived/input_output/data/p03073/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03073/Kotlin/s605387421.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s605387421", "user_id": "u863309603"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n println(Math.min(f(s), f(s.reversed())))\n}\n\nprivate fun f(s: String): Int {\n if (s.length == 1) {\n return 0\n }\n\n var c = s[0]\n\n return s.substring(1).map {\n if (c == it) {\n c = if (c == '0') '1' else '0'\n 1\n } else {\n c = it\n 0\n }\n }.sum()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03073", "source_text": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 322, "memory_kb": 36500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s777734375", "group_id": "codeNet:p03073", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n\n val len = s.length\n var p1 = \"\"\n var p2 = \"\"\n for (i in 1..len) {\n if (i % 2 == 0) {\n p1 += \"0\"\n p2 += \"1\"\n } else {\n p1 += \"1\"\n p2 += \"0\"\n }\n }\n\n var diff1 = 0\n var diff2 = 0\n for (i in 0 until len) {\n if (s[i] != p1[i]) {\n diff1++\n }\n if (s[i] != p2[i]) {\n diff2++\n }\n }\n println(Math.min(diff1, diff2))\n}", "language": "Kotlin", "metadata": {"date": 1555182868, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03073/input.txt", "sample_output_relpath": "derived/input_output/data/p03073/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03073/Kotlin/s777734375.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s777734375", "user_id": "u367259152"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n\n val len = s.length\n var p1 = \"\"\n var p2 = \"\"\n for (i in 1..len) {\n if (i % 2 == 0) {\n p1 += \"0\"\n p2 += \"1\"\n } else {\n p1 += \"1\"\n p2 += \"0\"\n }\n }\n\n var diff1 = 0\n var diff2 = 0\n for (i in 0 until len) {\n if (s[i] != p1[i]) {\n diff1++\n }\n if (s[i] != p2[i]) {\n diff2++\n }\n }\n println(Math.min(diff1, diff2))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03073", "source_text": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 511, "cpu_time_ms": 2111, "memory_kb": 116848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s113492284", "group_id": "codeNet:p03075", "input_text": "fun main(args: Array) {\n val a = readLine()!!.toInt()\n repeat(3) { readLine() }\n val e = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n println(if (e - a > k) \":(\" else \"Yay!\")\n}", "language": "Kotlin", "metadata": {"date": 1554599854, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Kotlin/s113492284.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s113492284", "user_id": "u863309603"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "fun main(args: Array) {\n val a = readLine()!!.toInt()\n repeat(3) { readLine() }\n val e = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n println(if (e - a > k) \":(\" else \"Yay!\")\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 206, "cpu_time_ms": 205, "memory_kb": 31604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s668010183", "group_id": "codeNet:p03076", "input_text": "fun main(args: Array) {\n val A = IntArray(5)\n repeat(5) { i ->\n A[i] = readLine()!!.toInt()\n }\n val B = A.map { ((it + 9) / 10) * 10 }\n val max = A.zip(B).maxBy { it.second - it.first }!!\n println(B.sum() - max.second + max.first)\n}", "language": "Kotlin", "metadata": {"date": 1590180620, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Kotlin/s668010183.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s668010183", "user_id": "u860789370"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "fun main(args: Array) {\n val A = IntArray(5)\n repeat(5) { i ->\n A[i] = readLine()!!.toInt()\n }\n val B = A.map { ((it + 9) / 10) * 10 }\n val max = A.zip(B).maxBy { it.second - it.first }!!\n println(B.sum() - max.second + max.first)\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 224, "memory_kb": 35860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s507078594", "group_id": "codeNet:p03076", "input_text": "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 val d = sc.nextInt()\n val e = sc.nextInt()\n println(problem123b(a, b, c, d, e))\n}\n\nfun problem123b(a: Int, b: Int, c: Int, d: Int, e: Int): Int {\n var sum = 0\n val list = listOf(a, b, c, d, e)\n val zeros = list.filter { it.toString().last().toString().toInt() == 0 }\n val other = list.sortedByDescending { it.toString().last().toString().toInt() }\n .filter { it.toString().last().toString().toInt() != 0 }\n return other\n .map { if (it >= 10) (it.toString().dropLast(1).toString().toInt() + 1) * 10 else 10 }\n .dropLast(1)\n .sum() + zeros.sum() + (other.lastOrNull() ?: 0)\n}", "language": "Kotlin", "metadata": {"date": 1581091899, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Kotlin/s507078594.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s507078594", "user_id": "u073232808"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "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 val d = sc.nextInt()\n val e = sc.nextInt()\n println(problem123b(a, b, c, d, e))\n}\n\nfun problem123b(a: Int, b: Int, c: Int, d: Int, e: Int): Int {\n var sum = 0\n val list = listOf(a, b, c, d, e)\n val zeros = list.filter { it.toString().last().toString().toInt() == 0 }\n val other = list.sortedByDescending { it.toString().last().toString().toInt() }\n .filter { it.toString().last().toString().toInt() != 0 }\n return other\n .map { if (it >= 10) (it.toString().dropLast(1).toString().toInt() + 1) * 10 else 10 }\n .dropLast(1)\n .sum() + zeros.sum() + (other.lastOrNull() ?: 0)\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 787, "cpu_time_ms": 213, "memory_kb": 33920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s041193067", "group_id": "codeNet:p03076", "input_text": "fun main(args: Array) {\n val X = (1..5).map { readLine()!!.toInt() }\n .sortedByDescending { (it % 10).let { i -> if (i == 0) Int.MAX_VALUE else i } }\n .mapIndexed { index, it -> if (it % 10 == 0 || index == 4) it else 10 * (it / 10 + 1) }\n println(X.sum())\n}", "language": "Kotlin", "metadata": {"date": 1554577901, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Kotlin/s041193067.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s041193067", "user_id": "u771276989"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "fun main(args: Array) {\n val X = (1..5).map { readLine()!!.toInt() }\n .sortedByDescending { (it % 10).let { i -> if (i == 0) Int.MAX_VALUE else i } }\n .mapIndexed { index, it -> if (it % 10 == 0 || index == 4) it else 10 * (it / 10 + 1) }\n println(X.sum())\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 232, "memory_kb": 35980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s298406678", "group_id": "codeNet:p03077", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val l = Array(5) { readLine()!!.toInt() }\n print(N / (l.min()!!) + 4)\n}", "language": "Kotlin", "metadata": {"date": 1561972578, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/Kotlin/s298406678.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s298406678", "user_id": "u089528214"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val l = Array(5) { readLine()!!.toInt() }\n print(N / (l.min()!!) + 4)\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 143, "cpu_time_ms": 218, "memory_kb": 32220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s488171076", "group_id": "codeNet:p03079", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val set = longSet()\n repeat(3){ set.add(nextLong()) }\n\n println(if(set.siz == 1L) \"Yes\" else \"No\")\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1588604521, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03079/input.txt", "sample_output_relpath": "derived/input_output/data/p03079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03079/Kotlin/s488171076.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s488171076", "user_id": "u581625805"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.BigDecimal\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val set = longSet()\n repeat(3){ set.add(nextLong()) }\n\n println(if(set.siz == 1L) \"Yes\" else \"No\")\n\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03079", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 14267, "cpu_time_ms": 205, "memory_kb": 34096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s524032838", "group_id": "codeNet:p03079", "input_text": "fun main(args: Array) {\n println(if (readLine()!!.split(\" \").toSet().size == 1) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1585089255, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03079/input.txt", "sample_output_relpath": "derived/input_output/data/p03079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03079/Kotlin/s524032838.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s524032838", "user_id": "u733811860"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n println(if (readLine()!!.split(\" \").toSet().size == 1) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03079", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 239, "memory_kb": 37944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s624353313", "group_id": "codeNet:p03080", "input_text": "fun main(args:Array?): Unit {\n val n = readLine()!!.toInt()\n println(\n if (readLine()!!.trim().count{it == 'R'} * 2 > n) \"Yes\" else \"No\"\n )\n}", "language": "Kotlin", "metadata": {"date": 1553976350, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03080.html", "problem_id": "p03080", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03080/input.txt", "sample_output_relpath": "derived/input_output/data/p03080/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03080/Kotlin/s624353313.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s624353313", "user_id": "u419330815"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array?): Unit {\n val n = readLine()!!.toInt()\n println(\n if (readLine()!!.trim().count{it == 'R'} * 2 > n) \"Yes\" else \"No\"\n )\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "sample_input": "4\nRRBR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03080", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 169, "cpu_time_ms": 211, "memory_kb": 33788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s926881990", "group_id": "codeNet:p03085", "input_text": "fun main(args:Array) {\n val b = readLine()!!.toString()\n\n println(when(b){\n \"A\"->\"T\"\n \"T\"->\"A\"\n \"C\"->\"G\"\n \"G\"->\"C\"\n else->\"\"\n })\n}\n", "language": "Kotlin", "metadata": {"date": 1553457796, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Kotlin/s926881990.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s926881990", "user_id": "u122997134"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "fun main(args:Array) {\n val b = readLine()!!.toString()\n\n println(when(b){\n \"A\"->\"T\"\n \"T\"->\"A\"\n \"C\"->\"G\"\n \"G\"->\"C\"\n else->\"\"\n })\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 199, "memory_kb": 31776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s305391996", "group_id": "codeNet:p03086", "input_text": "fun main() {\n val S = readLine()!!\n var max = 0\n val l = listOf(\"A\", \"C\", \"G\", \"T\")\n for (i in S.indices) {\n var ix = i\n var cnt = 0\n while (ix <= S.length-1 && S[ix].toString() in l) {\n cnt ++\n ix ++\n }\n if (cnt > max) {\n max = cnt\n }\n }\n println(max)\n}", "language": "Kotlin", "metadata": {"date": 1597431378, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03086/input.txt", "sample_output_relpath": "derived/input_output/data/p03086/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03086/Kotlin/s305391996.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s305391996", "user_id": "u437444592"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n val S = readLine()!!\n var max = 0\n val l = listOf(\"A\", \"C\", \"G\", \"T\")\n for (i in S.indices) {\n var ix = i\n var cnt = 0\n while (ix <= S.length-1 && S[ix].toString() in l) {\n cnt ++\n ix ++\n }\n if (cnt > max) {\n max = cnt\n }\n }\n println(max)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 347, "cpu_time_ms": 113, "memory_kb": 37980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s525414438", "group_id": "codeNet:p03086", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n var count = 0\n var max = 0\n s.toCharArray().forEach { \n if (it == 'A' || it == 'T' || it == 'G' || it == 'C') count++\n else {\n if (max < count) max = count\n count = 0\n }\n }\n println(max)\n}\n", "language": "Kotlin", "metadata": {"date": 1579903165, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03086/input.txt", "sample_output_relpath": "derived/input_output/data/p03086/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03086/Kotlin/s525414438.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s525414438", "user_id": "u396701320"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n var count = 0\n var max = 0\n s.toCharArray().forEach { \n if (it == 'A' || it == 'T' || it == 'G' || it == 'C') count++\n else {\n if (max < count) max = count\n count = 0\n }\n }\n println(max)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 305, "cpu_time_ms": 201, "memory_kb": 31764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s101401333", "group_id": "codeNet:p03087", "input_text": "fun main(args: Array) = yorukatsu15c()\n\nfun yorukatsu15c() {\n val (n, q) = readLine()!!.split(' ').map { it.toInt() }\n val s = readLine()!!\n val lrList = (1..q).map {\n readLine()!!.split(' ').map { it.toInt() }.let { it[0] to it[1] }\n }\n\n val cSum = IntArray(n + 1)\n\n for (i in 1..s.lastIndex) {\n cSum[i] = if (s[i - 1] == 'A' && s[i] == 'C') 1 else 0\n }\n for (i in 0 until n) cSum[i + 1] += cSum[i]\n\n val answer = lrList.map {\n val (left, right) = it\n cSum[right - 1] - cSum[left - 1]\n }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1586892181, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03087/input.txt", "sample_output_relpath": "derived/input_output/data/p03087/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03087/Kotlin/s101401333.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s101401333", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu15c()\n\nfun yorukatsu15c() {\n val (n, q) = readLine()!!.split(' ').map { it.toInt() }\n val s = readLine()!!\n val lrList = (1..q).map {\n readLine()!!.split(' ').map { it.toInt() }.let { it[0] to it[1] }\n }\n\n val cSum = IntArray(n + 1)\n\n for (i in 1..s.lastIndex) {\n cSum[i] = if (s[i - 1] == 'A' && s[i] == 'C') 1 else 0\n }\n for (i in 0 until n) cSum[i + 1] += cSum[i]\n\n val answer = lrList.map {\n val (left, right) = it\n cSum[right - 1] - cSum[left - 1]\n }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 698, "memory_kb": 68276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s894573411", "group_id": "codeNet:p03087", "input_text": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!\n var l = (1..y).map{ readLine()!!.split(\" \").map { it.toInt() } }\n var acl = mutableListOf(-1.0)\n for(i in 0 until s.count()){\n if (s[i] == 'A' && s[i + 1] == 'C'){\n acl.add(i + 1.5)\n }\n }\n println(acl)\n for(j in 0 until y){\n println(acl.filter{ it -> it > l[j][0] && it < l[j][1] }.count())\n }\n}", "language": "Kotlin", "metadata": {"date": 1553463175, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03087/input.txt", "sample_output_relpath": "derived/input_output/data/p03087/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03087/Kotlin/s894573411.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s894573411", "user_id": "u227189389"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!\n var l = (1..y).map{ readLine()!!.split(\" \").map { it.toInt() } }\n var acl = mutableListOf(-1.0)\n for(i in 0 until s.count()){\n if (s[i] == 'A' && s[i + 1] == 'C'){\n acl.add(i + 1.5)\n }\n }\n println(acl)\n for(j in 0 until y){\n println(acl.filter{ it -> it > l[j][0] && it < l[j][1] }.count())\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 466, "cpu_time_ms": 2111, "memory_kb": 129884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s486059109", "group_id": "codeNet:p03087", "input_text": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val (n, q) = readLine()!!.split(' ').map{it.toInt()}\n val s = readLine()!!\n val ans = Array(n, {0})\n\n var cnt = 0\n var f = false\n for ((i, x) in s.withIndex()) {\n if (!f and (x == 'A')) {\n f = true\n } else if (!f) {\n f = false\n } else if (f and (x =='C')) {\n f = false\n cnt += 1\n } else if (f) {\n f = false\n }\n ans[i] = cnt\n }\n\n for (i in 0 until q) {\n val (l, r) = readLine()!!.split(' ').map{it.toInt()-1}\n println(ans[r] - ans[l])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1553458997, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03087/input.txt", "sample_output_relpath": "derived/input_output/data/p03087/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03087/Kotlin/s486059109.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s486059109", "user_id": "u868099754"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val (n, q) = readLine()!!.split(' ').map{it.toInt()}\n val s = readLine()!!\n val ans = Array(n, {0})\n\n var cnt = 0\n var f = false\n for ((i, x) in s.withIndex()) {\n if (!f and (x == 'A')) {\n f = true\n } else if (!f) {\n f = false\n } else if (f and (x =='C')) {\n f = false\n cnt += 1\n } else if (f) {\n f = false\n }\n ans[i] = cnt\n }\n\n for (i in 0 until q) {\n val (l, r) = readLine()!!.split(' ').map{it.toInt()-1}\n println(ans[r] - ans[l])\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 650, "cpu_time_ms": 1263, "memory_kb": 67512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s918463724", "group_id": "codeNet:p03090", "input_text": "fun main(args: Array){\n val N = readLine()!!.toInt()\n val pair = Array((N+1)/2){ mutableSetOf() }\n if(N % 2 == 0){\n for(i in 1..N/2){\n pair[i - 1].add(i)\n pair[i - 1].add(N - i + 1)\n }\n }else{\n for(i in 1..(N - 1)/2){\n pair[i - 1].add(i)\n pair[i - 1].add(N - i)\n }\n pair[(N+1)/2 - 1].add(N)\n }\n\n val v = mutableListOf>()\n for(i in 0 until pair.size - 1){\n pair[i].forEach { p1 ->\n pair[i+1].forEach { p2 ->\n v.add(Pair(p1, p2))\n }\n }\n }\n if(pair.size > 2){\n pair[pair.size - 1].forEach { p1 ->\n pair[0].forEach { p2 ->\n v.add(Pair(p1, p2))\n }\n }\n }\n\n println(v.size)\n println(v.map { \"${it.first} ${it.second}\" }.joinToString(separator = \"\\n\"))\n}", "language": "Kotlin", "metadata": {"date": 1591721368, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03090.html", "problem_id": "p03090", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03090/input.txt", "sample_output_relpath": "derived/input_output/data/p03090/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03090/Kotlin/s918463724.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918463724", "user_id": "u531770859"}, "prompt_components": {"gold_output": "2\n1 3\n2 3\n", "input_to_evaluate": "fun main(args: Array){\n val N = readLine()!!.toInt()\n val pair = Array((N+1)/2){ mutableSetOf() }\n if(N % 2 == 0){\n for(i in 1..N/2){\n pair[i - 1].add(i)\n pair[i - 1].add(N - i + 1)\n }\n }else{\n for(i in 1..(N - 1)/2){\n pair[i - 1].add(i)\n pair[i - 1].add(N - i)\n }\n pair[(N+1)/2 - 1].add(N)\n }\n\n val v = mutableListOf>()\n for(i in 0 until pair.size - 1){\n pair[i].forEach { p1 ->\n pair[i+1].forEach { p2 ->\n v.add(Pair(p1, p2))\n }\n }\n }\n if(pair.size > 2){\n pair[pair.size - 1].forEach { p1 ->\n pair[0].forEach { p2 ->\n v.add(Pair(p1, p2))\n }\n }\n }\n\n println(v.size)\n println(v.map { \"${it.first} ${it.second}\" }.joinToString(separator = \"\\n\"))\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N.\nBuild an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\nThe graph is simple and connected.\n\nThere exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.\n\nIt can be proved that at least one such graph exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIn the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.\n\nThe output will be judged correct if the graph satisfies the conditions.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n1 3\n2 3\n\nFor every vertex, the sum of the indices of the vertices adjacent to that vertex is 3.", "sample_input": "3\n"}, "reference_outputs": ["2\n1 3\n2 3\n"], "source_document_id": "p03090", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N.\nBuild an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\nThe graph is simple and connected.\n\nThere exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.\n\nIt can be proved that at least one such graph exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIn the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.\n\nThe output will be judged correct if the graph satisfies the conditions.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n1 3\n2 3\n\nFor every vertex, the sum of the indices of the vertices adjacent to that vertex is 3.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 891, "cpu_time_ms": 234, "memory_kb": 37928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s072519881", "group_id": "codeNet:p03095", "input_text": "fun main(Args: Array) {\n val N = readLine().toString()\n val S = readLine()\n\n val strings = S!!.toCharArray()\n\n val array = Array(26) {0}\n strings.forEach { array[it.toInt()-'a'.toInt()]++ }\n\n var ans = 1\n array.forEach { if (it > 0) ans *= (it+1)}\n ans--\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1553278020, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03095/input.txt", "sample_output_relpath": "derived/input_output/data/p03095/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03095/Kotlin/s072519881.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s072519881", "user_id": "u801173061"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "fun main(Args: Array) {\n val N = readLine().toString()\n val S = readLine()\n\n val strings = S!!.toCharArray()\n\n val array = Array(26) {0}\n strings.forEach { array[it.toInt()-'a'.toInt()]++ }\n\n var ans = 1\n array.forEach { if (it > 0) ans *= (it+1)}\n ans--\n\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "sample_input": "4\nabcd\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03095", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 254, "memory_kb": 34724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s396731971", "group_id": "codeNet:p03095", "input_text": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n val c = Array(26, {1L})\n s.forEach{\n c[it - 'a'] = c[it - 'a'] + 1\n }\n val res = c.reduce { l, r ->\n (l * r) % MOD\n }\n println(res-1)\n}\n", "language": "Kotlin", "metadata": {"date": 1552927686, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03095/input.txt", "sample_output_relpath": "derived/input_output/data/p03095/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03095/Kotlin/s396731971.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s396731971", "user_id": "u868099754"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = readLine()!!\n\n val c = Array(26, {1L})\n s.forEach{\n c[it - 'a'] = c[it - 'a'] + 1\n }\n val res = c.reduce { l, r ->\n (l * r) % MOD\n }\n println(res-1)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "sample_input": "4\nabcd\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03095", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 300, "cpu_time_ms": 252, "memory_kb": 34632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s066391443", "group_id": "codeNet:p03101", "input_text": "fun main(args: Array) {\n abc121a()\n}\n\nfun abc121a() {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val whites = H * W\n val blacks = H * w + W * h - h * w\n println(whites - blacks)\n}\n", "language": "Kotlin", "metadata": {"date": 1589643813, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03101/input.txt", "sample_output_relpath": "derived/input_output/data/p03101/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03101/Kotlin/s066391443.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066391443", "user_id": "u628907033"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n abc121a()\n}\n\nfun abc121a() {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n val whites = H * W\n val blacks = H * w + W * h - h * w\n println(whites - blacks)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 278, "cpu_time_ms": 244, "memory_kb": 37824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s474995363", "group_id": "codeNet:p03101", "input_text": "fun main(args: Array) {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n\n println((H - h) * (W - w))\n}", "language": "Kotlin", "metadata": {"date": 1552161732, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03101/input.txt", "sample_output_relpath": "derived/input_output/data/p03101/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03101/Kotlin/s474995363.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s474995363", "user_id": "u367259152"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W) = readLine()!!.split(\" \").map { it.toInt() }\n val (h, w) = readLine()!!.split(\" \").map { it.toInt() }\n\n println((H - h) * (W - w))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 238, "memory_kb": 37880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s224410086", "group_id": "codeNet:p03102", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val c = sc.nextInt()\n val b = (1..m).map { sc.nextInt() }\n val anm = mutableListOf>()\n for (i in 0 until n) {\n val ai = (1..m).map { sc.nextInt() }\n anm.add(ai)\n }\n println(abc121b(n, m, c, b, anm))\n}\n\nprivate fun abc121b(n: Int, m: Int, c: Int, b: List, anm: List>): Int {\n var count = 0\n for (ai in anm) {\n var sum = 0\n for (j in 0 until m) {\n sum += ai.get(j) * b.get(j)\n\n }\n sum += c\n if (sum > 0) count++\n }\n\n return count\n}\n", "language": "Kotlin", "metadata": {"date": 1590269657, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03102/input.txt", "sample_output_relpath": "derived/input_output/data/p03102/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03102/Kotlin/s224410086.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224410086", "user_id": "u323522006"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val c = sc.nextInt()\n val b = (1..m).map { sc.nextInt() }\n val anm = mutableListOf>()\n for (i in 0 until n) {\n val ai = (1..m).map { sc.nextInt() }\n anm.add(ai)\n }\n println(abc121b(n, m, c, b, anm))\n}\n\nprivate fun abc121b(n: Int, m: Int, c: Int, b: List, anm: List>): Int {\n var count = 0\n for (ai in anm) {\n var sum = 0\n for (j in 0 until m) {\n sum += ai.get(j) * b.get(j)\n\n }\n sum += c\n if (sum > 0) count++\n }\n\n return count\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "sample_input": "2 3 -10\n1 2 3\n3 2 1\n1 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03102", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 622, "cpu_time_ms": 207, "memory_kb": 31384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s470419844", "group_id": "codeNet:p03102", "input_text": "fun main(args:Array) {\n val (n,m,c) = readLine()!!.split(\" \").map { it.toInt() }\n val list = readLine()!!.split(\" \").map { it.toInt() }\n\n var ans = 0\n (1..n).forEach {\n val src = readLine()!!.split(\" \").map { it.toInt() }\n val total = (0 until m).map { list[it]*src[it] }.sum()\n if (total + c > 0) {\n ans+=1\n }\n }\n println(ans)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1578414910, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03102/input.txt", "sample_output_relpath": "derived/input_output/data/p03102/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03102/Kotlin/s470419844.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470419844", "user_id": "u269969976"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args:Array) {\n val (n,m,c) = readLine()!!.split(\" \").map { it.toInt() }\n val list = readLine()!!.split(\" \").map { it.toInt() }\n\n var ans = 0\n (1..n).forEach {\n val src = readLine()!!.split(\" \").map { it.toInt() }\n val total = (0 until m).map { list[it]*src[it] }.sum()\n if (total + c > 0) {\n ans+=1\n }\n }\n println(ans)\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "sample_input": "2 3 -10\n1 2 3\n3 2 1\n1 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03102", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 396, "cpu_time_ms": 242, "memory_kb": 37648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s945301122", "group_id": "codeNet:p03102", "input_text": "fun main(args: Array) {\n val (N, M, C) = readLine()!!.split(\" \").map { it.toInt() }\n val B = readLine()!!.split(\" \").map { it.toInt() }\n var result = 0\n\n for (i in 0 until N) {\n val A = readLine()!!.split(\" \").map { it.toInt() }\n var s = 0\n for (j in 0 until M) s += A[j] * B[j]\n if (s + C > 0) result++\n }\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1552162132, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03102/input.txt", "sample_output_relpath": "derived/input_output/data/p03102/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03102/Kotlin/s945301122.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s945301122", "user_id": "u771276989"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M, C) = readLine()!!.split(\" \").map { it.toInt() }\n val B = readLine()!!.split(\" \").map { it.toInt() }\n var result = 0\n\n for (i in 0 until N) {\n val A = readLine()!!.split(\" \").map { it.toInt() }\n var s = 0\n for (j in 0 until M) s += A[j] * B[j]\n if (s + C > 0) result++\n }\n println(result)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "sample_input": "2 3 -10\n1 2 3\n3 2 1\n1 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03102", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 379, "cpu_time_ms": 244, "memory_kb": 37688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s758764213", "group_id": "codeNet:p03103", "input_text": "\nfun main(args:Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val shopList = (1..n).map { readLine()!!.split(\" \").map { it.toLong() } }.sortedBy { it[0] }\n\n var ans = 0L\n var count = 0L\n for(shop in shopList) {\n val buyCount = Math.min(shop[1], (m - count).toLong())\n ans += buyCount*shop[0]\n count += buyCount\n if(count >= m) {\n break\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1578415299, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/Kotlin/s758764213.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s758764213", "user_id": "u269969976"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "\nfun main(args:Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val shopList = (1..n).map { readLine()!!.split(\" \").map { it.toLong() } }.sortedBy { it[0] }\n\n var ans = 0L\n var count = 0L\n for(shop in shopList) {\n val buyCount = Math.min(shop[1], (m - count).toLong())\n ans += buyCount*shop[0]\n count += buyCount\n if(count >= m) {\n break\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 452, "cpu_time_ms": 845, "memory_kb": 85660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s981685261", "group_id": "codeNet:p03103", "input_text": "\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val pairAandB = mutableListOf>()\n\n (1..N).forEach {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n pairAandB.add(Pair(a,b))\n }\n\n pairAandB.sortBy { it.first }\n\n var totalCost = 0L\n var count = 0L\n\n pairAandB.forEach {\n var cost = it.first\n var remainder = it.second\n while(remainder > 0) {\n totalCost += cost\n remainder--\n count++\n if (count == M.toLong()) {\n println(totalCost)\n return\n }\n }\n }\n println(totalCost)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1552163675, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/Kotlin/s981685261.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s981685261", "user_id": "u861095163"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val pairAandB = mutableListOf>()\n\n (1..N).forEach {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n pairAandB.add(Pair(a,b))\n }\n\n pairAandB.sortBy { it.first }\n\n var totalCost = 0L\n var count = 0L\n\n pairAandB.forEach {\n var cost = it.first\n var remainder = it.second\n while(remainder > 0) {\n totalCost += cost\n remainder--\n count++\n if (count == M.toLong()) {\n println(totalCost)\n return\n }\n }\n }\n println(totalCost)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 694, "cpu_time_ms": 875, "memory_kb": 80760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s640523564", "group_id": "codeNet:p03106", "input_text": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val (A, B, K) = readLine()!!.split(\" \").map { it.toInt() }\n val C = min(A, B)\n var list = mutableListOf()\n\n for (i in 1..(C/2)) {\n if (C % i == 0) {\n list.add(i)\n }\n }\n\n if (max(A, B) % C == 0) {\n list.add(C)\n }\n\n val ans = list.sortedDescending()[K-1]\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1597472653, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03106/input.txt", "sample_output_relpath": "derived/input_output/data/p03106/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03106/Kotlin/s640523564.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s640523564", "user_id": "u437444592"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main() {\n val (A, B, K) = readLine()!!.split(\" \").map { it.toInt() }\n val C = min(A, B)\n var list = mutableListOf()\n\n for (i in 1..(C/2)) {\n if (C % i == 0) {\n list.add(i)\n }\n }\n\n if (max(A, B) % C == 0) {\n list.add(C)\n }\n\n val ans = list.sortedDescending()[K-1]\n\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "sample_input": "8 12 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03106", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 394, "cpu_time_ms": 125, "memory_kb": 39012}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s594353076", "group_id": "codeNet:p03107", "input_text": "import java.lang.Math.sqrt\n\nconst val MOD = 1000000007L\nconst val INF = 1000000007L\n\n\nfun main(args: Array) {\n val s = readList().first()\n\n var c0 = 0\n var c1 = 0\n var ans = 0\n s.forEach {\n when (it) {\n '0' -> {\n if (c1 > 0) {\n c1--\n ans += 2\n } else {\n c0++\n }\n }\n '1' -> {\n if (c0 > 0) {\n c0--\n ans += 2\n } else {\n c1++\n }\n }\n }\n }\n println(ans)\n}\n\nfun readList() = readLine()!!.split(' ')\nfun readInt() = readLine()!!.split(' ').map(String::toInt).first()\nfun readIntList() = readList().map(String::toInt)\nfun readLongList() = readList().map(String::toLong)\nfun readDoubleList() = readList().map(String::toDouble)\n\nfun readPair(): Pair {\n val splite = readLine()!!.split(' ')\n return Pair(splite[0], splite[1])\n}\n\nfun List.copy() = this.map { it }\n\nfun Long.toBinaryString(): String {\n var t = this\n var res = \"\"\n while (t > 0) {\n res += (t % 2).toString()\n t /= 2\n }\n return res\n}\n\ninline fun dualArray(h: Int, w: Int, init: (Int, Int) -> T) {\n Array(h) { i ->\n return@Array Array(w) { j ->\n return@Array init(i, j)\n }\n }\n}\n\n// 速度のためforEachは避ける\ninline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\ninline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = sqrt(value.toDouble()).toLong()\n val former = mutableListOf()\n val latter = mutableListOf()\n (1..max).filter { value % it == 0L }\n .forEach {\n former.add(it)\n latter.add(value / it)\n }\n former.addAll(latter.reversed())\n return former\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\n// 二分探索\nfun List.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {\n var start = (_start - 1).toLong()\n var end = _end.toLong()\n while (end - start > 1) {\n val mid = (start + end) / 2\n if (this[mid.toInt()] < target) {\n start = mid\n } else {\n end = mid\n }\n }\n return end.toInt()\n}\n\n// bit全探索\ninline fun Int.bitAllSearch(body: (Array) -> Unit) {\n for (bit in 0 until (1 shl this)) {\n val s = mutableListOf()\n for (i in 0 until this) {\n if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか\n s.add(i)\n }\n }\n body(s.toTypedArray())\n }\n}\n\n\ninternal class UnionFindTree(size: Int) {\n\n private val parent = Array(size) {\n return@Array it\n }\n private val rank = Array(size) {\n return@Array 0\n }\n\n fun union(x: Int, y: Int): Int {\n val xRoot = find(x)\n val yRoot = find(y)\n\n if (xRoot == yRoot) return xRoot\n\n when {\n rank[xRoot] > rank[yRoot] -> parent[yRoot] = xRoot\n rank[xRoot] < rank[yRoot] -> parent[xRoot] = yRoot\n xRoot != yRoot -> {\n parent[yRoot] = xRoot\n rank[xRoot]++\n }\n }\n return parent[xRoot]\n }\n\n fun find(i: Int): Int {\n if (i != parent[i]) {\n parent[i] = find(parent[i])\n }\n return parent[i]\n }\n\n fun same(x: Int, y: Int): Boolean {\n return find(x) == find(y)\n }\n}", "language": "Kotlin", "metadata": {"date": 1565820979, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03107.html", "problem_id": "p03107", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03107/input.txt", "sample_output_relpath": "derived/input_output/data/p03107/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03107/Kotlin/s594353076.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s594353076", "user_id": "u718935188"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.lang.Math.sqrt\n\nconst val MOD = 1000000007L\nconst val INF = 1000000007L\n\n\nfun main(args: Array) {\n val s = readList().first()\n\n var c0 = 0\n var c1 = 0\n var ans = 0\n s.forEach {\n when (it) {\n '0' -> {\n if (c1 > 0) {\n c1--\n ans += 2\n } else {\n c0++\n }\n }\n '1' -> {\n if (c0 > 0) {\n c0--\n ans += 2\n } else {\n c1++\n }\n }\n }\n }\n println(ans)\n}\n\nfun readList() = readLine()!!.split(' ')\nfun readInt() = readLine()!!.split(' ').map(String::toInt).first()\nfun readIntList() = readList().map(String::toInt)\nfun readLongList() = readList().map(String::toLong)\nfun readDoubleList() = readList().map(String::toDouble)\n\nfun readPair(): Pair {\n val splite = readLine()!!.split(' ')\n return Pair(splite[0], splite[1])\n}\n\nfun List.copy() = this.map { it }\n\nfun Long.toBinaryString(): String {\n var t = this\n var res = \"\"\n while (t > 0) {\n res += (t % 2).toString()\n t /= 2\n }\n return res\n}\n\ninline fun dualArray(h: Int, w: Int, init: (Int, Int) -> T) {\n Array(h) { i ->\n return@Array Array(w) { j ->\n return@Array init(i, j)\n }\n }\n}\n\n// 速度のためforEachは避ける\ninline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\ninline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {\n for (i in start until if (shiftLast) this + start else this) {\n body(i)\n }\n}\n\n// 約数のList\nfun divisor(value: Long): List {\n val max = sqrt(value.toDouble()).toLong()\n val former = mutableListOf()\n val latter = mutableListOf()\n (1..max).filter { value % it == 0L }\n .forEach {\n former.add(it)\n latter.add(value / it)\n }\n former.addAll(latter.reversed())\n return former\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from: Long, to: Long = from): List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value: Long): List {\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a: Long, b: Long): Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base: String, a: String, b: String): String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\n// 二分探索\nfun List.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {\n var start = (_start - 1).toLong()\n var end = _end.toLong()\n while (end - start > 1) {\n val mid = (start + end) / 2\n if (this[mid.toInt()] < target) {\n start = mid\n } else {\n end = mid\n }\n }\n return end.toInt()\n}\n\n// bit全探索\ninline fun Int.bitAllSearch(body: (Array) -> Unit) {\n for (bit in 0 until (1 shl this)) {\n val s = mutableListOf()\n for (i in 0 until this) {\n if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか\n s.add(i)\n }\n }\n body(s.toTypedArray())\n }\n}\n\n\ninternal class UnionFindTree(size: Int) {\n\n private val parent = Array(size) {\n return@Array it\n }\n private val rank = Array(size) {\n return@Array 0\n }\n\n fun union(x: Int, y: Int): Int {\n val xRoot = find(x)\n val yRoot = find(y)\n\n if (xRoot == yRoot) return xRoot\n\n when {\n rank[xRoot] > rank[yRoot] -> parent[yRoot] = xRoot\n rank[xRoot] < rank[yRoot] -> parent[xRoot] = yRoot\n xRoot != yRoot -> {\n parent[yRoot] = xRoot\n rank[xRoot]++\n }\n }\n return parent[xRoot]\n }\n\n fun find(i: Int): Int {\n if (i != parent[i]) {\n parent[i] = find(parent[i])\n }\n return parent[i]\n }\n\n fun same(x: Int, y: Int): Boolean {\n return find(x) == find(y)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4636, "cpu_time_ms": 284, "memory_kb": 39048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s883475383", "group_id": "codeNet:p03107", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val S = sc.next().toCharArray()\n var list = S.toList()\n var isRun = true\n var ans = 0\n while (isRun) {\n isRun = false\n var pre = 'N'\n var nextList = mutableListOf()\n for (c in list) {\n if (pre == c) {\n ans += 2\n nextList.removeAt(nextList.size-1)\n isRun = true\n }else {\n nextList.add(c)\n }\n pre = c\n }\n list = nextList\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1551645021, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03107.html", "problem_id": "p03107", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03107/input.txt", "sample_output_relpath": "derived/input_output/data/p03107/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03107/Kotlin/s883475383.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s883475383", "user_id": "u043557308"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val S = sc.next().toCharArray()\n var list = S.toList()\n var isRun = true\n var ans = 0\n while (isRun) {\n isRun = false\n var pre = 'N'\n var nextList = mutableListOf()\n for (c in list) {\n if (pre == c) {\n ans += 2\n nextList.removeAt(nextList.size-1)\n isRun = true\n }else {\n nextList.add(c)\n }\n pre = c\n }\n list = nextList\n }\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 598, "cpu_time_ms": 308, "memory_kb": 37640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s235624939", "group_id": "codeNet:p03108", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map{it.toInt()}\n val A = Array(M) {0}\n val B = Array(M) {0}\n\n for (i in A.indices) {\n val (a, b) = readLine()!!.split(\" \").map{it.toInt()}\n A[i] = a - 1\n B[i] = b - 1\n }\n\n val uf = UnionFind(N)\n val res = ArrayList()\n res.add(N * (N - 1L) / 2)\n\n for (i in A.indices.reversed()) {\n if (uf.same(A[i], B[i])) {\n res.add(res.last())\n } else {\n res.add(res.last() - uf.getCardinalityOf(A[i]) * uf.getCardinalityOf(B[i]))\n uf.unite(A[i], B[i])\n }\n }\n\n res.removeAt(res.size - 1)\n res.reverse()\n for (v in res) {\n println(v)\n }\n}\n\nprivate class UnionFind(n: Int) {\n val size = n\n\n private val parent: Array\n private val cardinality: Array\n\n init {\n parent = Array(size) { -1 }\n cardinality = Array(size) { 1L }\n }\n\n /**\n * Find a root element of a set `x` belongs to.\n */\n fun find(x: Int): Int {\n return if (parent[x] == -1) {\n x\n } else {\n parent[x] = find(parent[x])\n parent[x]\n }\n }\n\n /**\n * Unite sets contain two elements `x` and `y`.\n * If `x` and `y` already belong to a same set, nothing happens.\n *\n * @return If `x` and `y` belong to a same set, return false.\n */\n fun unite(x: Int, y: Int): Boolean {\n val u = find(x)\n val v = find(y)\n if (u == v) {\n return false\n }\n\n val newSize = cardinality[v] + cardinality[u]\n\n if (cardinality[u] < cardinality[v]) {\n parent[u] = v\n cardinality[v] = newSize\n } else {\n parent[v] = u\n cardinality[u] = newSize\n }\n\n return true\n }\n\n /**\n * Check whether `x` and `y` belongs to a same set.\n *\n * @return `true` if `x` and `y` are in a same set.\n */\n fun same(x: Int, y: Int): Boolean {\n return find(x) == find(y)\n }\n\n /**\n * Get a size of a set `x` belongs to.\n */\n fun getCardinalityOf(x: Int): Long {\n return cardinality[find(x)]\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1577189976, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03108/input.txt", "sample_output_relpath": "derived/input_output/data/p03108/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03108/Kotlin/s235624939.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235624939", "user_id": "u183530284"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map{it.toInt()}\n val A = Array(M) {0}\n val B = Array(M) {0}\n\n for (i in A.indices) {\n val (a, b) = readLine()!!.split(\" \").map{it.toInt()}\n A[i] = a - 1\n B[i] = b - 1\n }\n\n val uf = UnionFind(N)\n val res = ArrayList()\n res.add(N * (N - 1L) / 2)\n\n for (i in A.indices.reversed()) {\n if (uf.same(A[i], B[i])) {\n res.add(res.last())\n } else {\n res.add(res.last() - uf.getCardinalityOf(A[i]) * uf.getCardinalityOf(B[i]))\n uf.unite(A[i], B[i])\n }\n }\n\n res.removeAt(res.size - 1)\n res.reverse()\n for (v in res) {\n println(v)\n }\n}\n\nprivate class UnionFind(n: Int) {\n val size = n\n\n private val parent: Array\n private val cardinality: Array\n\n init {\n parent = Array(size) { -1 }\n cardinality = Array(size) { 1L }\n }\n\n /**\n * Find a root element of a set `x` belongs to.\n */\n fun find(x: Int): Int {\n return if (parent[x] == -1) {\n x\n } else {\n parent[x] = find(parent[x])\n parent[x]\n }\n }\n\n /**\n * Unite sets contain two elements `x` and `y`.\n * If `x` and `y` already belong to a same set, nothing happens.\n *\n * @return If `x` and `y` belong to a same set, return false.\n */\n fun unite(x: Int, y: Int): Boolean {\n val u = find(x)\n val v = find(y)\n if (u == v) {\n return false\n }\n\n val newSize = cardinality[v] + cardinality[u]\n\n if (cardinality[u] < cardinality[v]) {\n parent[u] = v\n cardinality[v] = newSize\n } else {\n parent[v] = u\n cardinality[u] = newSize\n }\n\n return true\n }\n\n /**\n * Check whether `x` and `y` belongs to a same set.\n *\n * @return `true` if `x` and `y` are in a same set.\n */\n fun same(x: Int, y: Int): Boolean {\n return find(x) == find(y)\n }\n\n /**\n * Get a size of a set `x` belongs to.\n */\n fun getCardinalityOf(x: Int): Long {\n return cardinality[find(x)]\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2212, "cpu_time_ms": 1360, "memory_kb": 81904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s285026409", "group_id": "codeNet:p03108", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val ab = Array(m) { sc.nextInt() to sc.nextInt() }\n\n val group = IntArray(n + 1) { it }\n val rank = LongArray(n + 1)\n val count = LongArray(n + 1) { 1 }\n\n fun find(index: Int): Int {\n return if (group[index] == index) {\n index\n } else {\n group[index] = find(group[index])\n group[index]\n }\n }\n\n fun unite(x: Int, y: Int) {\n val nx = find(x)\n val ny = find(y)\n\n if (nx == ny) return\n\n if (rank[nx] < rank[ny]) {\n group[ny] = nx\n } else {\n group[nx] = ny\n if (rank[nx] == rank[ny]) rank[nx]++\n }\n }\n\n val ret = LongArray(m + 1)\n (0 until ab.size).reversed().forEach { index ->\n val x = ab[index].first\n val y = ab[index].second\n\n val gx = find(x)\n val gy = find(y)\n\n if (gx == gy) {\n ret[index] = ret[index + 1]\n return@forEach\n }\n\n unite(gx, gy)\n (count[gx] * count[gy]).let {\n ret[index] = ret[index + 1] + it\n count[find(gx)] = count[gx] + count[gy]\n }\n }\n\n ret.drop(1).forEachIndexed { index, v ->\n println(ret.first() - ret[index + 1])\n }\n\n\n}", "language": "Kotlin", "metadata": {"date": 1555722590, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03108/input.txt", "sample_output_relpath": "derived/input_output/data/p03108/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03108/Kotlin/s285026409.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285026409", "user_id": "u153537680"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val ab = Array(m) { sc.nextInt() to sc.nextInt() }\n\n val group = IntArray(n + 1) { it }\n val rank = LongArray(n + 1)\n val count = LongArray(n + 1) { 1 }\n\n fun find(index: Int): Int {\n return if (group[index] == index) {\n index\n } else {\n group[index] = find(group[index])\n group[index]\n }\n }\n\n fun unite(x: Int, y: Int) {\n val nx = find(x)\n val ny = find(y)\n\n if (nx == ny) return\n\n if (rank[nx] < rank[ny]) {\n group[ny] = nx\n } else {\n group[nx] = ny\n if (rank[nx] == rank[ny]) rank[nx]++\n }\n }\n\n val ret = LongArray(m + 1)\n (0 until ab.size).reversed().forEach { index ->\n val x = ab[index].first\n val y = ab[index].second\n\n val gx = find(x)\n val gy = find(y)\n\n if (gx == gy) {\n ret[index] = ret[index + 1]\n return@forEach\n }\n\n unite(gx, gy)\n (count[gx] * count[gy]).let {\n ret[index] = ret[index + 1] + it\n count[find(gx)] = count[gx] + count[gy]\n }\n }\n\n ret.drop(1).forEachIndexed { index, v ->\n println(ret.first() - ret[index + 1])\n }\n\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1363, "cpu_time_ms": 1380, "memory_kb": 87716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s609985773", "group_id": "codeNet:p03108", "input_text": "import java.util.*\n\nobject MainKt {\n\t@JvmStatic\n\tfun main(args: Array) {\n\t\tval scanner = Scanner(System.`in`)\n\t\tval n: Int = scanner.nextInt()\n\t\tval m: Int = scanner.nextInt()\n\t\tval bridges: Array?> = arrayOfNulls(m)\n\t\tfor (i in 0..m-1) {\n\t\t\tval a = scanner.nextInt()\n\t\t\tval b = scanner.nextInt()\n\t\t\tbridges[i] = (Pair(a, b))\n\t\t}\n\n\t\tval allComb: Long = n.toLong()*(n-1)/2\n\n\t\tval answers: Array = arrayOfNulls(m)\n\t\tval landKey = mutableMapOf()\n\t\tval keyMap = mutableMapOf>()\n\t\tvar nextKey = 0\n\n\t\tanswers[m-1] = allComb\n\n\t\tfor (i in m-2 downTo 0) {\n\t\t\tval (a, b) = bridges[i+1]!!\n\t\t\tval hasA = landKey.contains(a)\n\t\t\tval hasB = landKey.contains(b)\n\t\t\tif (!hasA && !hasB) {\n\t\t\t\tlandKey[a] = nextKey\n\t\t\t\tlandKey[b] = nextKey\n\t\t\t\tkeyMap[nextKey] = mutableListOf(a, b)\n\t\t\t\tnextKey++\n\t\t\t}else if (!hasA && hasB) {\n\t\t\t\tval key = landKey[b]!!\n\t\t\t\tlandKey[a] = key\n\t\t\t\tkeyMap[key]!!.add(a)\n\t\t\t}else if (hasA && !hasB) {\n\t\t\t\tval key = landKey[a]!!\n\t\t\t\tlandKey[b] = key\n\t\t\t\tkeyMap[key]!!.add(b)\n\t\t\t}else {\n\t\t\t\tval keyA = landKey[a]!!\n\t\t\t\tval keyB = landKey[b]!!\n\t\t\t\tif (keyA!=keyB) {\n\t\t\t\t\tval key = Math.min(keyA, keyB)\n\t\t\t\t\tval oldKey = Math.max(keyA, keyB)\n\t\t\t\t\tkeyMap[oldKey]!!.forEach { l -> landKey[l] = key }\n\t\t\t\t\tkeyMap[key]!!.addAll(keyMap[oldKey]!!)\n\t\t\t\t\tkeyMap.remove(oldKey)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar ans: Long = allComb\n\t\t\tkeyMap.forEach {\n\t\t\t\tval size = it.value.size.toLong()\n\t\t\t\tans -= size*(size-1)/2\n\t\t\t}\n\t\t\tanswers[i] = ans\n\n\t\t\tif (i!=0 && ans==0L) {\n\t\t\t\tfor (j in 0..i-1) answers[j] = 0\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tanswers.forEach(::println)\n\t}\n}", "language": "Kotlin", "metadata": {"date": 1551650245, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03108/input.txt", "sample_output_relpath": "derived/input_output/data/p03108/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03108/Kotlin/s609985773.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s609985773", "user_id": "u914590612"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "import java.util.*\n\nobject MainKt {\n\t@JvmStatic\n\tfun main(args: Array) {\n\t\tval scanner = Scanner(System.`in`)\n\t\tval n: Int = scanner.nextInt()\n\t\tval m: Int = scanner.nextInt()\n\t\tval bridges: Array?> = arrayOfNulls(m)\n\t\tfor (i in 0..m-1) {\n\t\t\tval a = scanner.nextInt()\n\t\t\tval b = scanner.nextInt()\n\t\t\tbridges[i] = (Pair(a, b))\n\t\t}\n\n\t\tval allComb: Long = n.toLong()*(n-1)/2\n\n\t\tval answers: Array = arrayOfNulls(m)\n\t\tval landKey = mutableMapOf()\n\t\tval keyMap = mutableMapOf>()\n\t\tvar nextKey = 0\n\n\t\tanswers[m-1] = allComb\n\n\t\tfor (i in m-2 downTo 0) {\n\t\t\tval (a, b) = bridges[i+1]!!\n\t\t\tval hasA = landKey.contains(a)\n\t\t\tval hasB = landKey.contains(b)\n\t\t\tif (!hasA && !hasB) {\n\t\t\t\tlandKey[a] = nextKey\n\t\t\t\tlandKey[b] = nextKey\n\t\t\t\tkeyMap[nextKey] = mutableListOf(a, b)\n\t\t\t\tnextKey++\n\t\t\t}else if (!hasA && hasB) {\n\t\t\t\tval key = landKey[b]!!\n\t\t\t\tlandKey[a] = key\n\t\t\t\tkeyMap[key]!!.add(a)\n\t\t\t}else if (hasA && !hasB) {\n\t\t\t\tval key = landKey[a]!!\n\t\t\t\tlandKey[b] = key\n\t\t\t\tkeyMap[key]!!.add(b)\n\t\t\t}else {\n\t\t\t\tval keyA = landKey[a]!!\n\t\t\t\tval keyB = landKey[b]!!\n\t\t\t\tif (keyA!=keyB) {\n\t\t\t\t\tval key = Math.min(keyA, keyB)\n\t\t\t\t\tval oldKey = Math.max(keyA, keyB)\n\t\t\t\t\tkeyMap[oldKey]!!.forEach { l -> landKey[l] = key }\n\t\t\t\t\tkeyMap[key]!!.addAll(keyMap[oldKey]!!)\n\t\t\t\t\tkeyMap.remove(oldKey)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar ans: Long = allComb\n\t\t\tkeyMap.forEach {\n\t\t\t\tval size = it.value.size.toLong()\n\t\t\t\tans -= size*(size-1)/2\n\t\t\t}\n\t\t\tanswers[i] = ans\n\n\t\t\tif (i!=0 && ans==0L) {\n\t\t\t\tfor (j in 0..i-1) answers[j] = 0\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tanswers.forEach(::println)\n\t}\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1602, "cpu_time_ms": 2111, "memory_kb": 90592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s462926739", "group_id": "codeNet:p03109", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(problem119a(s))\n}\n\nfun problem119a(s: String): String {\n return if (s.take(4).toInt() >= 2019 && s.drop(5).take(2).toInt() >= 5) \"TBD\" else \"Heisei\"\n}", "language": "Kotlin", "metadata": {"date": 1591558437, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03109/input.txt", "sample_output_relpath": "derived/input_output/data/p03109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03109/Kotlin/s462926739.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s462926739", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(problem119a(s))\n}\n\nfun problem119a(s: String): String {\n return if (s.take(4).toInt() >= 2019 && s.drop(5).take(2).toInt() >= 5) \"TBD\" else \"Heisei\"\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "sample_input": "2019/04/30\n"}, "reference_outputs": ["Heisei\n"], "source_document_id": "p03109", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 273, "cpu_time_ms": 180, "memory_kb": 30992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s920192844", "group_id": "codeNet:p03110", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n println((1..n).map {\n val x = sc.nextDouble()\n when (sc.next()){\n \"JPY\" -> x\n else -> x * 380000\n }\n }.sum())\n}", "language": "Kotlin", "metadata": {"date": 1584179267, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03110/input.txt", "sample_output_relpath": "derived/input_output/data/p03110/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03110/Kotlin/s920192844.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s920192844", "user_id": "u733811860"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n println((1..n).map {\n val x = sc.nextDouble()\n when (sc.next()){\n \"JPY\" -> x\n else -> x * 380000\n }\n }.sum())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "sample_input": "2\n10000 JPY\n0.10000000 BTC\n"}, "reference_outputs": ["48000.0\n"], "source_document_id": "p03110", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 272, "cpu_time_ms": 203, "memory_kb": 31400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s561948241", "group_id": "codeNet:p03125", "input_text": "fun main(args: Array) {\n\n val (a, b) = readLine()!!.split(\" \").map{it.toInt()}\n\n if(b % a == 0) println(a + b) else println(b - a)\n}\n", "language": "Kotlin", "metadata": {"date": 1557680492, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03125/input.txt", "sample_output_relpath": "derived/input_output/data/p03125/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03125/Kotlin/s561948241.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561948241", "user_id": "u108272327"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "fun main(args: Array) {\n\n val (a, b) = readLine()!!.split(\" \").map{it.toInt()}\n\n if(b % a == 0) println(a + b) else println(b - a)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 237, "memory_kb": 36120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s781487527", "group_id": "codeNet:p03125", "input_text": "fun main(args:Array){val (a,b)=readLine()!!.split(' ').map{it.toInt()};println(if (b%a==0)a+b else b-a)}", "language": "Kotlin", "metadata": {"date": 1550377157, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03125/input.txt", "sample_output_relpath": "derived/input_output/data/p03125/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03125/Kotlin/s781487527.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s781487527", "user_id": "u166163326"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "fun main(args:Array){val (a,b)=readLine()!!.split(' ').map{it.toInt()};println(if (b%a==0)a+b else b-a)}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 112, "cpu_time_ms": 233, "memory_kb": 36520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s929691887", "group_id": "codeNet:p03126", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (n, m) = listOfInt()\n val pref = IntArray(m){0}\n\n repeat(n) {\n val aa = listOfInt().drop(1)\n aa.forEach {\n pref[it-1]++\n }\n }\n\n println(pref.count { it == n })\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1570010727, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Kotlin/s929691887.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929691887", "user_id": "u262403099"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (n, m) = listOfInt()\n val pref = IntArray(m){0}\n\n repeat(n) {\n val aa = listOfInt().drop(1)\n aa.forEach {\n pref[it-1]++\n }\n }\n\n println(pref.count { it == n })\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 519, "cpu_time_ms": 243, "memory_kb": 37868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s896265273", "group_id": "codeNet:p03126", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n\n val res = IntArray(m) { 0 }\n\n repeat(n) {\n val a = readLine()!!.split(' ').map { it.toInt() }\n (1..a[0]).forEach {\n res[a[it - 1]]++\n }\n }\n\n println(res.filter { it == n }.count())\n}", "language": "Kotlin", "metadata": {"date": 1550369653, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Kotlin/s896265273.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s896265273", "user_id": "u863309603"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n\n val res = IntArray(m) { 0 }\n\n repeat(n) {\n val a = readLine()!!.split(' ').map { it.toInt() }\n (1..a[0]).forEach {\n res[a[it - 1]]++\n }\n }\n\n println(res.filter { it == n }.count())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 320, "cpu_time_ms": 238, "memory_kb": 38260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s004933773", "group_id": "codeNet:p03127", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val s = Scanner(System.`in`)\n val n = s.nextInt()\n val a: MutableList = mutableListOf()\n for (i in 1..n) {\n a.add(s.nextInt())\n }\n\n println(solve(a))\n}\n\nfun solve(a: List): Int {\n var r: Int = 0\n for (i in a) {\n r = gcd(r, i)\n }\n return r\n}\n\nfun gcd(a: Int, b: Int): Int {\n if (b == 0) {\n return a\n }\n\n return gcd(b, a % b)\n}\n", "language": "Kotlin", "metadata": {"date": 1554576742, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Kotlin/s004933773.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004933773", "user_id": "u090225501"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val s = Scanner(System.`in`)\n val n = s.nextInt()\n val a: MutableList = mutableListOf()\n for (i in 1..n) {\n a.add(s.nextInt())\n }\n\n println(solve(a))\n}\n\nfun solve(a: List): Int {\n var r: Int = 0\n for (i in a) {\n r = gcd(r, i)\n }\n return r\n}\n\nfun gcd(a: Int, b: Int): Int {\n if (b == 0) {\n return a\n }\n\n return gcd(b, a % b)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 455, "cpu_time_ms": 547, "memory_kb": 55476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s618375899", "group_id": "codeNet:p03127", "input_text": "fun main(args: Array) {\n readLine()\n var a = readLine()!!.split(' ').map(String::toInt)\n var min: Int\n do {\n min = a.min()!!\n if (min == 1) break\n a = a.map { if (it == min) min else it % min }.filter { it != 0 }.distinct()\n } while (1 < a.size)\n println(min)\n}\n", "language": "Kotlin", "metadata": {"date": 1550376788, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Kotlin/s618375899.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s618375899", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()\n var a = readLine()!!.split(' ').map(String::toInt)\n var min: Int\n do {\n min = a.min()!!\n if (min == 1) break\n a = a.map { if (it == min) min else it % min }.filter { it != 0 }.distinct()\n } while (1 < a.size)\n println(min)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 524, "memory_kb": 56016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s044642409", "group_id": "codeNet:p03127", "input_text": "fun main(args: Array) {\n val size = readLine()!!.toInt()\n val hp = readLine()!!.split(' ').map(String::toInt)\n val last = hp.reduce(::gcd)\n println(last)\n}\n\nfun gcd(a: Int, b: Int): Int {\n if(a < b) return gcd(b, a)\n if(b == 0) return a\n return gcd(b, a % b)\n}", "language": "Kotlin", "metadata": {"date": 1550369909, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/Kotlin/s044642409.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044642409", "user_id": "u166163326"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val size = readLine()!!.toInt()\n val hp = readLine()!!.split(' ').map(String::toInt)\n val last = hp.reduce(::gcd)\n println(last)\n}\n\nfun gcd(a: Int, b: Int): Int {\n if(a < b) return gcd(b, a)\n if(b == 0) return a\n return gcd(b, a % b)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 289, "cpu_time_ms": 452, "memory_kb": 51916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s995019961", "group_id": "codeNet:p03128", "input_text": "fun isNewBiggerThanOld(new: String, old: String) : Boolean {\n if (new.length != old.length) {\n return new.length > old.length\n }\n var i = 0\n while (i < new.length) {\n if (new[i] > old[i]) {\n return true\n } else if (new[i] < old[i]) {\n return false\n }\n i++\n }\n // Other\n return false\n}\n\nfun generateNext(str: String, number: Char) : String {\n val buffer = StringBuffer()\n var used = false\n var i = 0\n while (i < str.length) {\n val c = str[i]\n if (used) {\n buffer.append(str.substring(i))\n break\n }\n\n if (!used && number > c) {\n buffer.append(number)\n buffer.append(c)\n used = true\n } else {\n buffer.append(c)\n }\n i++\n }\n\n if (!used) {\n buffer.append(number)\n }\n\n return buffer.toString()\n}\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toCharArray()[0] }.sorted()\n val numToCost = listOf(-1, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n val default = \"\"\n val dp = Array(N + 1, { default })\n\n (1..N).forEach { i ->\n var max = dp[i]\n A.forEach {\n val num = it\n val cost = numToCost[num - '0']\n if (i - cost >= 0) {\n if (dp[i-cost] == \"\") {\n if (i - cost == 0) {\n max = num.toString()\n }\n } else {\n val new = generateNext(dp[i-cost], num)\n if (isNewBiggerThanOld(new, max)) {\n max = new\n }\n }\n }\n }\n dp[i] = max\n }\n println(dp[N])\n}", "language": "Kotlin", "metadata": {"date": 1564723484, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Kotlin/s995019961.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s995019961", "user_id": "u861095163"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "fun isNewBiggerThanOld(new: String, old: String) : Boolean {\n if (new.length != old.length) {\n return new.length > old.length\n }\n var i = 0\n while (i < new.length) {\n if (new[i] > old[i]) {\n return true\n } else if (new[i] < old[i]) {\n return false\n }\n i++\n }\n // Other\n return false\n}\n\nfun generateNext(str: String, number: Char) : String {\n val buffer = StringBuffer()\n var used = false\n var i = 0\n while (i < str.length) {\n val c = str[i]\n if (used) {\n buffer.append(str.substring(i))\n break\n }\n\n if (!used && number > c) {\n buffer.append(number)\n buffer.append(c)\n used = true\n } else {\n buffer.append(c)\n }\n i++\n }\n\n if (!used) {\n buffer.append(number)\n }\n\n return buffer.toString()\n}\nfun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toCharArray()[0] }.sorted()\n val numToCost = listOf(-1, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n val default = \"\"\n val dp = Array(N + 1, { default })\n\n (1..N).forEach { i ->\n var max = dp[i]\n A.forEach {\n val num = it\n val cost = numToCost[num - '0']\n if (i - cost >= 0) {\n if (dp[i-cost] == \"\") {\n if (i - cost == 0) {\n max = num.toString()\n }\n } else {\n val new = generateNext(dp[i-cost], num)\n if (isNewBiggerThanOld(new, max)) {\n max = new\n }\n }\n }\n }\n dp[i] = max\n }\n println(dp[N])\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1803, "cpu_time_ms": 1234, "memory_kb": 169368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s303031118", "group_id": "codeNet:p03128", "input_text": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toCharArray()[0] }\n val numToCost = mapOf(\n '1' to 2,\n '2' to 5,\n '3' to 5,//\n '4' to 4, //4\n '5' to 5,\n '6' to 6,\n '7' to 3,//\n '8' to 7,//\n '9' to 6\n )\n val dp = Array(N + 1, { \"\" })\n fun isNewBiggerThanOld(new: String, old: String) : Boolean {\n if (new.length != old.length) {\n return new.length > old.length\n }\n\n var i = 0\n while (i < new.length) {\n if (new[i] > old[i]) {\n return true\n }\n i++\n }\n // Other\n return false\n }\n\n fun generateNext(str: String, number: Char) : String {\n val buffer = StringBuffer()\n var used = false\n str.forEach {\n if (!used && number > it) {\n buffer.append(number)\n buffer.append(it)\n used = true\n } else {\n buffer.append(it)\n }\n }\n\n if (!used) {\n buffer.append(number)\n used = true\n }\n\n return buffer.toString()\n }\n\n (1..N).forEach { i ->\n var max = dp[i]\n A.forEach {\n val num = it\n val cost = numToCost[num]!!\n // try others\n if (i - cost >= 0) {\n if (dp[i-cost] == \"\") {\n if (i - cost == 0) {\n max = num.toString()\n }\n } else {\n val new = generateNext(dp[i-cost], num)\n if (isNewBiggerThanOld(new, max)) {\n max = new\n }\n }\n }\n }\n dp[i] = max\n }\n println(dp[N])\n}", "language": "Kotlin", "metadata": {"date": 1564720514, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Kotlin/s303031118.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s303031118", "user_id": "u861095163"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toCharArray()[0] }\n val numToCost = mapOf(\n '1' to 2,\n '2' to 5,\n '3' to 5,//\n '4' to 4, //4\n '5' to 5,\n '6' to 6,\n '7' to 3,//\n '8' to 7,//\n '9' to 6\n )\n val dp = Array(N + 1, { \"\" })\n fun isNewBiggerThanOld(new: String, old: String) : Boolean {\n if (new.length != old.length) {\n return new.length > old.length\n }\n\n var i = 0\n while (i < new.length) {\n if (new[i] > old[i]) {\n return true\n }\n i++\n }\n // Other\n return false\n }\n\n fun generateNext(str: String, number: Char) : String {\n val buffer = StringBuffer()\n var used = false\n str.forEach {\n if (!used && number > it) {\n buffer.append(number)\n buffer.append(it)\n used = true\n } else {\n buffer.append(it)\n }\n }\n\n if (!used) {\n buffer.append(number)\n used = true\n }\n\n return buffer.toString()\n }\n\n (1..N).forEach { i ->\n var max = dp[i]\n A.forEach {\n val num = it\n val cost = numToCost[num]!!\n // try others\n if (i - cost >= 0) {\n if (dp[i-cost] == \"\") {\n if (i - cost == 0) {\n max = num.toString()\n }\n } else {\n val new = generateNext(dp[i-cost], num)\n if (isNewBiggerThanOld(new, max)) {\n max = new\n }\n }\n }\n }\n dp[i] = max\n }\n println(dp[N])\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1908, "cpu_time_ms": 2108, "memory_kb": 169744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s503938937", "group_id": "codeNet:p03128", "input_text": "fun main(args: Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n val match = intArrayOf(0,2,5,5,4,5,6,3,7,6)\n\n val dp = IntArray(n+10){-1}\n dp[0] = 0\n repeat(n) { i ->\n a.forEach { dp[i+match[it]] = Math.max(dp[i+match[it]], dp[i] + 1 ) }\n }\n\n var ans = \"\"\n var l = n\n while(ans.length) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n val match = intArrayOf(0,2,5,5,4,5,6,3,7,6)\n\n val dp = IntArray(n+10){-1}\n dp[0] = 0\n repeat(n) { i ->\n a.forEach { dp[i+match[it]] = Math.max(dp[i+match[it]], dp[i] + 1 ) }\n }\n\n var ans = \"\"\n var l = n\n while(ans.length) {\n val count = arrayOf(-1, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = IntArray(m) { sc.nextInt() }.sorted()\n val numbers = a.fold(mutableMapOf()) { acc, i ->\n val need = count[i]\n if (!acc.containsKey(need)) {\n acc[need] = i\n } else if (acc[need]!! < i) {\n acc[need] = i\n }\n\n acc\n }\n\n val numbersCount = numbers.map { it.value }.map { count[it] }.sorted()\n val minCount = numbersCount.first()\n\n val lcm = numbersCount.fold(1, ::lcm)\n val maxNum = Array>>(lcm + 1) {\n when (it) {\n 0 -> 0 to emptyList()\n else -> -1 to emptyList()\n }\n }\n\n maxNum.forEachIndexed { index, p ->\n if (p.first < 0) return@forEachIndexed\n\n numbers.forEach { entry ->\n val (need, num) = entry\n if (index + need < maxNum.size && maxNum[index + need].first < p.first + 1) {\n maxNum[index + need] = p.first + 1 to (p.second + num)\n }\n }\n\n }\n\n val r = (0..maxNum.size)\n .first { (n - it) % numbersCount.first() == 0 && maxNum[it].first >= 0 }\n\n val ret = (IntArray((n - r) / minCount) { numbers[minCount]!! }.toList() + maxNum[r].second)\n .sorted().reversed().joinToString(separator = \"\")\n println(ret)\n}\n\nfun gcd(a: Int, b: Int): Int {\n val c = a % b\n return if (c == 0) b else gcd(b, c)\n}\n\nfun lcm(a: Int, b: Int): Int {\n return a * b / gcd(a, b)\n}", "language": "Kotlin", "metadata": {"date": 1556398445, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Kotlin/s240298946.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s240298946", "user_id": "u153537680"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val count = arrayOf(-1, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val a = IntArray(m) { sc.nextInt() }.sorted()\n val numbers = a.fold(mutableMapOf()) { acc, i ->\n val need = count[i]\n if (!acc.containsKey(need)) {\n acc[need] = i\n } else if (acc[need]!! < i) {\n acc[need] = i\n }\n\n acc\n }\n\n val numbersCount = numbers.map { it.value }.map { count[it] }.sorted()\n val minCount = numbersCount.first()\n\n val lcm = numbersCount.fold(1, ::lcm)\n val maxNum = Array>>(lcm + 1) {\n when (it) {\n 0 -> 0 to emptyList()\n else -> -1 to emptyList()\n }\n }\n\n maxNum.forEachIndexed { index, p ->\n if (p.first < 0) return@forEachIndexed\n\n numbers.forEach { entry ->\n val (need, num) = entry\n if (index + need < maxNum.size && maxNum[index + need].first < p.first + 1) {\n maxNum[index + need] = p.first + 1 to (p.second + num)\n }\n }\n\n }\n\n val r = (0..maxNum.size)\n .first { (n - it) % numbersCount.first() == 0 && maxNum[it].first >= 0 }\n\n val ret = (IntArray((n - r) / minCount) { numbers[minCount]!! }.toList() + maxNum[r].second)\n .sorted().reversed().joinToString(separator = \"\")\n println(ret)\n}\n\nfun gcd(a: Int, b: Int): Int {\n val c = a % b\n return if (c == 0) b else gcd(b, c)\n}\n\nfun lcm(a: Int, b: Int): Int {\n return a * b / gcd(a, b)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1605, "cpu_time_ms": 256, "memory_kb": 36216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s914280091", "group_id": "codeNet:p03128", "input_text": "fun cmp(now : MutableList, next: MutableList) : Boolean{\n if(now.size < next.size) return true\n if(now.size > next.size) return false\n for(i in (now.size - 1).downTo(0)){\n if(now[i] < next[i]) return true\n if(now[i] > next[i]) return false\n }\n return false\n}\n\nfun addMatch(n : Int, i : Int, lx : MutableList>, la : MutableList){\n val remain = n - i\n if(i > 0 && lx[i].size == 0) return\n if(la[1] && remain >= 2){\n val lNow = lx[i + 2]\n var lNext = lx[i].toMutableList()\n lNext.add(1)\n if(cmp(lNow, lNext)) lx[i + 2] = lNext\n }\n if(la[2] && remain >= 5){\n val lNow = lx[i + 5]\n var lNext = lx[i].toMutableList()\n lNext.add(2)\n if(cmp(lNow, lNext)) lx[i + 5] = lNext\n }\n if(la[3] && remain >= 5){\n val lNow = lx[i + 5]\n var lNext = lx[i].toMutableList()\n lNext.add(3)\n if(cmp(lNow, lNext)) lx[i + 5] = lNext\n }\n if(la[4] && remain >= 4){\n val lNow = lx[i + 4]\n var lNext = lx[i].toMutableList()\n lNext.add(4)\n if(cmp(lNow, lNext)) lx[i + 4] = lNext\n }\n if(la[5] && remain >= 5){\n val lNow = lx[i + 5]\n var lNext = lx[i].toMutableList()\n lNext.add(5)\n if(cmp(lNow, lNext)) lx[i + 5] = lNext\n }\n if(la[6] && remain >= 6){\n val lNow = lx[i + 6]\n var lNext = lx[i].toMutableList()\n lNext.add(6)\n if(cmp(lNow, lNext)) lx[i + 6] = lNext\n }\n if(la[7] && remain >= 3){\n val lNow = lx[i + 3]\n var lNext = lx[i].toMutableList()\n lNext.add(7)\n if(cmp(lNow, lNext)) lx[i + 3] = lNext\n }\n if(la[8] && remain >= 7){\n val lNow = lx[i + 7]\n var lNext = lx[i].toMutableList()\n lNext.add(8)\n if(cmp(lNow, lNext)) lx[i + 7] = lNext\n }\n if(la[9] && remain >= 6){\n val lNow = lx[i + 6]\n var lNext = lx[i].toMutableList()\n lNext.add(9)\n if(cmp(lNow, lNext)) lx[i + 6] = lNext\n }\n}\n\nfun main(args: Array){\n var (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val l = readLine()!!.split(\" \").map(String::toInt)\n var la = mutableListOf()\n for(i in 0..9) {\n la.add(false)\n }\n l.forEach{\n la[it] = true\n }\n var lx : MutableList> = mutableListOf()\n for(i in 0..n){\n lx.add(mutableListOf())\n }\n for(i in 0..n){\n addMatch(n, i, lx, la)\n }\n\n for(i in (lx[n].size - 1).downTo(0)){\n //print(lx[n][i])\n }\n println()\n}\n", "language": "Kotlin", "metadata": {"date": 1551896603, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Kotlin/s914280091.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s914280091", "user_id": "u712822150"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "fun cmp(now : MutableList, next: MutableList) : Boolean{\n if(now.size < next.size) return true\n if(now.size > next.size) return false\n for(i in (now.size - 1).downTo(0)){\n if(now[i] < next[i]) return true\n if(now[i] > next[i]) return false\n }\n return false\n}\n\nfun addMatch(n : Int, i : Int, lx : MutableList>, la : MutableList){\n val remain = n - i\n if(i > 0 && lx[i].size == 0) return\n if(la[1] && remain >= 2){\n val lNow = lx[i + 2]\n var lNext = lx[i].toMutableList()\n lNext.add(1)\n if(cmp(lNow, lNext)) lx[i + 2] = lNext\n }\n if(la[2] && remain >= 5){\n val lNow = lx[i + 5]\n var lNext = lx[i].toMutableList()\n lNext.add(2)\n if(cmp(lNow, lNext)) lx[i + 5] = lNext\n }\n if(la[3] && remain >= 5){\n val lNow = lx[i + 5]\n var lNext = lx[i].toMutableList()\n lNext.add(3)\n if(cmp(lNow, lNext)) lx[i + 5] = lNext\n }\n if(la[4] && remain >= 4){\n val lNow = lx[i + 4]\n var lNext = lx[i].toMutableList()\n lNext.add(4)\n if(cmp(lNow, lNext)) lx[i + 4] = lNext\n }\n if(la[5] && remain >= 5){\n val lNow = lx[i + 5]\n var lNext = lx[i].toMutableList()\n lNext.add(5)\n if(cmp(lNow, lNext)) lx[i + 5] = lNext\n }\n if(la[6] && remain >= 6){\n val lNow = lx[i + 6]\n var lNext = lx[i].toMutableList()\n lNext.add(6)\n if(cmp(lNow, lNext)) lx[i + 6] = lNext\n }\n if(la[7] && remain >= 3){\n val lNow = lx[i + 3]\n var lNext = lx[i].toMutableList()\n lNext.add(7)\n if(cmp(lNow, lNext)) lx[i + 3] = lNext\n }\n if(la[8] && remain >= 7){\n val lNow = lx[i + 7]\n var lNext = lx[i].toMutableList()\n lNext.add(8)\n if(cmp(lNow, lNext)) lx[i + 7] = lNext\n }\n if(la[9] && remain >= 6){\n val lNow = lx[i + 6]\n var lNext = lx[i].toMutableList()\n lNext.add(9)\n if(cmp(lNow, lNext)) lx[i + 6] = lNext\n }\n}\n\nfun main(args: Array){\n var (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val l = readLine()!!.split(\" \").map(String::toInt)\n var la = mutableListOf()\n for(i in 0..9) {\n la.add(false)\n }\n l.forEach{\n la[it] = true\n }\n var lx : MutableList> = mutableListOf()\n for(i in 0..n){\n lx.add(mutableListOf())\n }\n for(i in 0..n){\n addMatch(n, i, lx, la)\n }\n\n for(i in (lx[n].size - 1).downTo(0)){\n //print(lx[n][i])\n }\n println()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2578, "cpu_time_ms": 2103, "memory_kb": 262372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s683141579", "group_id": "codeNet:p03128", "input_text": "import java.util.*\n\nval x = intArrayOf(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)\nval nums = mutableSetOf()\n\nfun main(args: Array) {\n\n val n = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n .sortedDescending()\n .distinctBy { it -> x[it] }\n .sortedDescending()\n\n for (i in a.indices) {\n find(\"\", n[0], a.drop(i))\n }\n \n println(nums.maxWith(Comparator { o1, o2 ->\n val len1 = o1.length\n val len2 = o2.length\n\n if (len1 != len2) {\n return@Comparator len1 - len2\n }\n\n for (i in 0 until len1) {\n val v1 = o1[i]\n val v2 = o2[i]\n if (v1 != v2) {\n return@Comparator v1 - v2\n }\n }\n\n 0\n }))\n\n}\n\nfun find(ans: String, rest: Int, a: List): String {\n if (rest == 0) {\n return ans\n } else if (rest < 0) {\n return \"-1\"\n }\n\n loop@ for ((i, v) in a.withIndex()) {\n val k = rest - x[v]\n val str = find(ans + v.toString(), k, a.drop(i))\n if (str != \"-1\") {\n nums.add(str)\n }\n }\n return \"-1\"\n}", "language": "Kotlin", "metadata": {"date": 1550376428, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Kotlin/s683141579.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s683141579", "user_id": "u604830826"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "import java.util.*\n\nval x = intArrayOf(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)\nval nums = mutableSetOf()\n\nfun main(args: Array) {\n\n val n = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n .sortedDescending()\n .distinctBy { it -> x[it] }\n .sortedDescending()\n\n for (i in a.indices) {\n find(\"\", n[0], a.drop(i))\n }\n \n println(nums.maxWith(Comparator { o1, o2 ->\n val len1 = o1.length\n val len2 = o2.length\n\n if (len1 != len2) {\n return@Comparator len1 - len2\n }\n\n for (i in 0 until len1) {\n val v1 = o1[i]\n val v2 = o2[i]\n if (v1 != v2) {\n return@Comparator v1 - v2\n }\n }\n\n 0\n }))\n\n}\n\nfun find(ans: String, rest: Int, a: List): String {\n if (rest == 0) {\n return ans\n } else if (rest < 0) {\n return \"-1\"\n }\n\n loop@ for ((i, v) in a.withIndex()) {\n val k = rest - x[v]\n val str = find(ans + v.toString(), k, a.drop(i))\n if (str != \"-1\") {\n nums.add(str)\n }\n }\n return \"-1\"\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1169, "cpu_time_ms": 2112, "memory_kb": 228180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s651579710", "group_id": "codeNet:p03135", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n println(sc.nextDouble() / sc.nextDouble())\n}", "language": "Kotlin", "metadata": {"date": 1583211139, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03135/input.txt", "sample_output_relpath": "derived/input_output/data/p03135/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03135/Kotlin/s651579710.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651579710", "user_id": "u733811860"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n println(sc.nextDouble() / sc.nextDouble())\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "sample_input": "8 3\n"}, "reference_outputs": ["2.6666666667\n"], "source_document_id": "p03135", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 134, "cpu_time_ms": 180, "memory_kb": 31272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s186446413", "group_id": "codeNet:p03137", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val x = readLine()!!.split(' ').map { it.toInt() }.sorted()\n\n val distances = IntArray(m) {0}\n var prev = x[0]\n var ans = x[x.size-1] - x[0]\n repeat(m) {\n val dist = x[it] - prev\n distances[it] = dist\n prev = x[it]\n }\n distances.sortDescending()\n\n\n repeat(Math.min(n-1,m)) {\n ans -= distances[it]\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1591845124, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Kotlin/s186446413.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s186446413", "user_id": "u288435405"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val x = readLine()!!.split(' ').map { it.toInt() }.sorted()\n\n val distances = IntArray(m) {0}\n var prev = x[0]\n var ans = x[x.size-1] - x[0]\n repeat(m) {\n val dist = x[it] - prev\n distances[it] = dist\n prev = x[it]\n }\n distances.sortDescending()\n\n\n repeat(Math.min(n-1,m)) {\n ans -= distances[it]\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 467, "cpu_time_ms": 808, "memory_kb": 54100}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s341346719", "group_id": "codeNet:p03137", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val M = sc.nextInt()\n if (N >= M) println(0)\n\n val X = IntArray(M){0}\n for (i in 0 until M) {//MをN個に区切る\n val x = sc.nextInt()\n X[i] = x\n }\n X.sort()\n\n val sub = IntArray(M-1){0}\n for (i in 0 until M-1) {\n sub[i] = X[i+1] - X[i]\n }\n sub.sort()\n println(sub.dropLast(N-1).sum())//ギャップが大きいところをなくすように区切る\n\n // 0 1 2 3 4 5\n // 1 1 1 1 1\n // 1 2 10 12 14\n // 1 8 2 2\n}", "language": "Kotlin", "metadata": {"date": 1553007914, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Kotlin/s341346719.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s341346719", "user_id": "u043557308"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val M = sc.nextInt()\n if (N >= M) println(0)\n\n val X = IntArray(M){0}\n for (i in 0 until M) {//MをN個に区切る\n val x = sc.nextInt()\n X[i] = x\n }\n X.sort()\n\n val sub = IntArray(M-1){0}\n for (i in 0 until M-1) {\n sub[i] = X[i+1] - X[i]\n }\n sub.sort()\n println(sub.dropLast(N-1).sum())//ギャップが大きいところをなくすように区切る\n\n // 0 1 2 3 4 5\n // 1 1 1 1 1\n // 1 2 10 12 14\n // 1 8 2 2\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 598, "cpu_time_ms": 636, "memory_kb": 52880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s874468188", "group_id": "codeNet:p03137", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val x = readLine()!!.split(\" \").map(String::toInt).sortedBy { it }\n val xd = (0 until m - 1).map { i -> Pair(i, x[i + 1] - x[i]) }\n .sortedByDescending { d -> d.second }\n val result = (n - 1 until m - 1).sumBy { i -> xd[i].second }\n println(result)\n}\n", "language": "Kotlin", "metadata": {"date": 1549247981, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Kotlin/s874468188.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874468188", "user_id": "u051841332"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n val x = readLine()!!.split(\" \").map(String::toInt).sortedBy { it }\n val xd = (0 until m - 1).map { i -> Pair(i, x[i + 1] - x[i]) }\n .sortedByDescending { d -> d.second }\n val result = (n - 1 until m - 1).sumBy { i -> xd[i].second }\n println(result)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 363, "cpu_time_ms": 918, "memory_kb": 76960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s593560309", "group_id": "codeNet:p03137", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val xs = readLine()!!.split(' ').map { it.toInt() }.sorted()\n\n val ds = mutableListOf();\n\n for (i in (0 until m - 1)) {\n ds.add(Math.abs(xs[i] - xs[i + 1]))\n }\n\n ds.sort()\n\n var res = 0\n for (i in (0 .. ds.size - n)) {\n res += ds[i]\n }\n println(res)\n}", "language": "Kotlin", "metadata": {"date": 1549246674, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Kotlin/s593560309.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593560309", "user_id": "u863309603"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n val xs = readLine()!!.split(' ').map { it.toInt() }.sorted()\n\n val ds = mutableListOf();\n\n for (i in (0 until m - 1)) {\n ds.add(Math.abs(xs[i] - xs[i + 1]))\n }\n\n ds.sort()\n\n var res = 0\n for (i in (0 .. ds.size - n)) {\n res += ds[i]\n }\n println(res)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 390, "cpu_time_ms": 937, "memory_kb": 54568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s305579290", "group_id": "codeNet:p03140", "input_text": "fun main(args: Array) {\n val n = readInteger()\n val a = readLine()!!\n val b = readLine()!!\n val c = readLine()!!\n \n var ans = 0\n for (i in 0 until n) {\n val tmp = listOf(a[i], b[i], c[i]).distinct().size\n if (tmp == 2) {\n ans++\n } else if (tmp == 3) {\n ans += 2\n }\n }\n println(ans)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1583682267, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03140.html", "problem_id": "p03140", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03140/input.txt", "sample_output_relpath": "derived/input_output/data/p03140/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03140/Kotlin/s305579290.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s305579290", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInteger()\n val a = readLine()!!\n val b = readLine()!!\n val c = readLine()!!\n \n var ans = 0\n for (i in 0 until n) {\n val tmp = listOf(a[i], b[i], c[i]).distinct().size\n if (tmp == 2) {\n ans++\n } else if (tmp == 3) {\n ans += 2\n }\n }\n println(ans)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "sample_input": "4\nwest\neast\nwait\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03140", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 231, "memory_kb": 35888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s772295178", "group_id": "codeNet:p03140", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val l = (0..2).map { readLine()!!.map { it } }\n print((0 until n).map { listOf(l[0][it], l[1][it], l[2][it]).distinct().size - 1 }.sum())\n}", "language": "Kotlin", "metadata": {"date": 1550089807, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03140.html", "problem_id": "p03140", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03140/input.txt", "sample_output_relpath": "derived/input_output/data/p03140/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03140/Kotlin/s772295178.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772295178", "user_id": "u384476909"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val l = (0..2).map { readLine()!!.map { it } }\n print((0 until n).map { listOf(l[0][it], l[1][it], l[2][it]).distinct().size - 1 }.sum())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "sample_input": "4\nwest\neast\nwait\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03140", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 211, "cpu_time_ms": 238, "memory_kb": 38336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s464489309", "group_id": "codeNet:p03141", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = (0 until n)\n .map {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n Triple(a, b, Math.abs(a - b))\n }\n .sortedByDescending { it.first }\n .sortedByDescending { it.third }\n val ans = xs\n .mapIndexed { index, triple -> if (index % 2 == 0) triple.first else -triple.second }\n .sum()\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1591761572, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Kotlin/s464489309.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s464489309", "user_id": "u863309603"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = (0 until n)\n .map {\n val (a, b) = readLine()!!.split(' ').map { it.toLong() }\n Triple(a, b, Math.abs(a - b))\n }\n .sortedByDescending { it.first }\n .sortedByDescending { it.third }\n val ans = xs\n .mapIndexed { index, triple -> if (index % 2 == 0) triple.first else -triple.second }\n .sum()\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 485, "cpu_time_ms": 1107, "memory_kb": 120476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s650897956", "group_id": "codeNet:p03141", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n val data = mutableListOf>()\n for (i in 1..n) {\n val (a, b) = readLine()!!.split(' ').map(String::toLong)\n data.add(Triple(b - a, a, b))\n }\n data.sortBy { -it.second }\n data.sortBy { -it.first }\n var sum = 0L\n for (i in 1..n) {\n sum += if (i % 2 == 1L) data.first().second else -data.first().third\n data.removeAt(0)\n }\n println(sum)\n}\n", "language": "Kotlin", "metadata": {"date": 1548643352, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Kotlin/s650897956.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s650897956", "user_id": "u099066216"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n val data = mutableListOf>()\n for (i in 1..n) {\n val (a, b) = readLine()!!.split(' ').map(String::toLong)\n data.add(Triple(b - a, a, b))\n }\n data.sortBy { -it.second }\n data.sortBy { -it.first }\n var sum = 0L\n for (i in 1..n) {\n sum += if (i % 2 == 1L) data.first().second else -data.first().third\n data.removeAt(0)\n }\n println(sum)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 481, "cpu_time_ms": 1996, "memory_kb": 126504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s595193811", "group_id": "codeNet:p03146", "input_text": "fun main(args : Array) {\n var s = readLine()!!.toInt()\n var nums = mutableSetOf()\n for (n in 2..1000000) {\n s = when(s % 2) {\n 0 -> s / 2\n else -> s * 3 + 1\n }\n if (nums.contains(s)){\n println(n)\n break\n } else {\n nums.add(s)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1573687562, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Kotlin/s595193811.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s595193811", "user_id": "u714769076"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args : Array) {\n var s = readLine()!!.toInt()\n var nums = mutableSetOf()\n for (n in 2..1000000) {\n s = when(s % 2) {\n 0 -> s / 2\n else -> s * 3 + 1\n }\n if (nums.contains(s)){\n println(n)\n break\n } else {\n nums.add(s)\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 349, "cpu_time_ms": 221, "memory_kb": 32416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s949724330", "group_id": "codeNet:p03146", "input_text": "fun main(args: Array) {\n val s = readLine()!!.toInt()\n var mlist = mutableListOf(s)\n var i = 0\n while(true) {\n val v = mlist.get(i)\n if(v%2==0) {\n val div = v/2\n if(mlist.contains(div)){\n println(i+2)\n break\n }\n mlist.add(div)\n } else{\n val mul = v*3 + 1\n if(mlist.contains(mul)){\n println(i+2)\n break\n }\n mlist.add(mul)\n }\n i++\n }\n}", "language": "Kotlin", "metadata": {"date": 1562167829, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Kotlin/s949724330.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949724330", "user_id": "u169088512"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!.toInt()\n var mlist = mutableListOf(s)\n var i = 0\n while(true) {\n val v = mlist.get(i)\n if(v%2==0) {\n val div = v/2\n if(mlist.contains(div)){\n println(i+2)\n break\n }\n mlist.add(div)\n } else{\n val mul = v*3 + 1\n if(mlist.contains(mul)){\n println(i+2)\n break\n }\n mlist.add(mul)\n }\n i++\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 429, "cpu_time_ms": 210, "memory_kb": 31816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s168957905", "group_id": "codeNet:p03147", "input_text": "fun main(args: Array) {\n\n\n val n = readLine()!!.toInt()\n val hn = readLine()!!.split(\" \").map(String::toInt).toTypedArray()\n\n var sum = 0\n while (true) {\n val start = hn.indexOfFirst { it != 0 }\n if (start == -1) {\n break\n }\n\n for (i in start until hn.size) {\n val v = hn[i]\n if (v == 0) {\n break;\n sum++\n }\n hn[i] = v - 1\n }\n sum++\n }\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1570032922, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/Kotlin/s168957905.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168957905", "user_id": "u085288971"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\n\n val n = readLine()!!.toInt()\n val hn = readLine()!!.split(\" \").map(String::toInt).toTypedArray()\n\n var sum = 0\n while (true) {\n val start = hn.indexOfFirst { it != 0 }\n if (start == -1) {\n break\n }\n\n for (i in start until hn.size) {\n val v = hn[i]\n if (v == 0) {\n break;\n sum++\n }\n hn[i] = v - 1\n }\n sum++\n }\n println(sum)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 504, "cpu_time_ms": 255, "memory_kb": 37988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s532716180", "group_id": "codeNet:p03147", "input_text": "fun main(args: Array) {\n val n = readInputLine().toInt()\n val hs = readInputLine().split(\" \").map{it.toInt()}.toList()\n \n println(dfs(hs, 0))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun split(list: List, height: Int): List> {\n val ret = mutableListOf>()\n \n var l = -1\n var splitting = false\n \n for ((i, e) in list.withIndex()) {\n if (!splitting && e > height) {\n l = i\n splitting = true\n } else if (splitting && e == height) {\n ret.add(list.subList(l, i))\n splitting = false\n }\n }\n \n if (splitting) {\n ret.add(list.subList(l, list.size))\n }\n \n return ret\n}\n\nfun dfs(list:List, height:Int): Int {\n var ret = 0\n val splitted = split(list, height)\n \n for (l in splitted) {\n ret += dfs(l, height + 1) + 1\n }\n \n return ret\n}\n", "language": "Kotlin", "metadata": {"date": 1564723664, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/Kotlin/s532716180.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s532716180", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readInputLine().toInt()\n val hs = readInputLine().split(\" \").map{it.toInt()}.toList()\n \n println(dfs(hs, 0))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun split(list: List, height: Int): List> {\n val ret = mutableListOf>()\n \n var l = -1\n var splitting = false\n \n for ((i, e) in list.withIndex()) {\n if (!splitting && e > height) {\n l = i\n splitting = true\n } else if (splitting && e == height) {\n ret.add(list.subList(l, i))\n splitting = false\n }\n }\n \n if (splitting) {\n ret.add(list.subList(l, list.size))\n }\n \n return ret\n}\n\nfun dfs(list:List, height:Int): Int {\n var ret = 0\n val splitted = split(list, height)\n \n for (l in splitted) {\n ret += dfs(l, height + 1) + 1\n }\n \n return ret\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 926, "cpu_time_ms": 296, "memory_kb": 38452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s789191626", "group_id": "codeNet:p03147", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var h = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n var i = 0\n var count = 0\n var countFlag = false\n while (h.sum() > 0) {\n if (h[i] > 0 && !countFlag) {\n h[i]--\n count++\n countFlag = true\n i++\n } else if (h[i] > 0) {\n h[i]--\n i++\n } else if ((h[i] == 0 && countFlag )|| (i == 8)) {\n i = 0\n countFlag = false\n } else {\n i++\n }\n }\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1548252976, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/Kotlin/s789191626.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s789191626", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var h = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n var i = 0\n var count = 0\n var countFlag = false\n while (h.sum() > 0) {\n if (h[i] > 0 && !countFlag) {\n h[i]--\n count++\n countFlag = true\n i++\n } else if (h[i] > 0) {\n h[i]--\n i++\n } else if ((h[i] == 0 && countFlag )|| (i == 8)) {\n i = 0\n countFlag = false\n } else {\n i++\n }\n }\n println(count)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 585, "cpu_time_ms": 2111, "memory_kb": 38756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s120938952", "group_id": "codeNet:p03149", "input_text": "fun main(args: Array) {\n keyence2019a()\n}\n\nfun keyence2019a() {\n val numbers = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = if (numbers.sorted() == listOf(1, 4, 7, 9)) \"YES\" else \"NO\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1571948605, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03149.html", "problem_id": "p03149", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03149/input.txt", "sample_output_relpath": "derived/input_output/data/p03149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03149/Kotlin/s120938952.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s120938952", "user_id": "u139478771"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n keyence2019a()\n}\n\nfun keyence2019a() {\n val numbers = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = if (numbers.sorted() == listOf(1, 4, 7, 9)) \"YES\" else \"NO\"\n\n println(answer)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "sample_input": "1 7 9 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03149", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 237, "cpu_time_ms": 233, "memory_kb": 36072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s571887665", "group_id": "codeNet:p03151", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }\n val bb = readLine()!!.split(\" \").map { it.toInt() }\n val diff = mutableListOf()\n\n for (i in 0 until n) {\n diff.add(Diff(i, (aa[i]-bb[i]).toLong()))\n }\n\n var ans = diff.count { it.diff < 0L }\n\n if (ans == 0) {\n println(0)\n return\n }\n\n var negSum = diff.fold(0L) { acc, diff ->\n if (diff.diff < 0L) acc + diff.diff else acc\n }\n\n val pos = diff.filter { it.diff > 0 }.sortedByDescending { it.diff }\n\n for (i in pos.indices) {\n ans++\n negSum += pos[i].diff\n if (negSum >= 0) {\n println(ans)\n return\n }\n }\n\n println(-1)\n}\n\ndata class Diff(val idx: Int, val diff: Long)", "language": "Kotlin", "metadata": {"date": 1593282952, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03151.html", "problem_id": "p03151", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03151/input.txt", "sample_output_relpath": "derived/input_output/data/p03151/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03151/Kotlin/s571887665.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s571887665", "user_id": "u262403099"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }\n val bb = readLine()!!.split(\" \").map { it.toInt() }\n val diff = mutableListOf()\n\n for (i in 0 until n) {\n diff.add(Diff(i, (aa[i]-bb[i]).toLong()))\n }\n\n var ans = diff.count { it.diff < 0L }\n\n if (ans == 0) {\n println(0)\n return\n }\n\n var negSum = diff.fold(0L) { acc, diff ->\n if (diff.diff < 0L) acc + diff.diff else acc\n }\n\n val pos = diff.filter { it.diff > 0 }.sortedByDescending { it.diff }\n\n for (i in pos.indices) {\n ans++\n negSum += pos[i].diff\n if (negSum >= 0) {\n println(ans)\n return\n }\n }\n\n println(-1)\n}\n\ndata class Diff(val idx: Int, val diff: Long)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "sample_input": "3\n2 3 5\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03151", "source_text": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 809, "cpu_time_ms": 648, "memory_kb": 66664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s575939954", "group_id": "codeNet:p03151", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n val b = (0 until n).map { sc.next().toLong() }\n println(problem2019c(n, a, b))\n}\n\nfun problem2019c(n: Int, a: List, b: List): Int {\n val diff = LongArray(n)\n var plusList = mutableListOf()\n val minusList = mutableListOf()\n for (i in 0 until n) {\n val diffI = a[i] - b[i]\n diff[i] = diffI\n if (diffI > 0) {\n plusList.add(diffI)\n } else if (diffI < 0) {\n minusList.add(diffI)\n }\n }\n if (minusList.isEmpty()) return 0\n if (plusList.sum() < Math.abs(minusList.sum())) return -1\n plusList = plusList.sortedDescending().toMutableList()\n val minusSum = Math.abs(minusList.sum())\n var count = 0\n var p = 0L\n for (i in 0 until plusList.size) {\n p += plusList[i]\n count++\n if (p >= minusSum) break\n }\n return minusList.count() + count\n}", "language": "Kotlin", "metadata": {"date": 1591133651, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03151.html", "problem_id": "p03151", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03151/input.txt", "sample_output_relpath": "derived/input_output/data/p03151/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03151/Kotlin/s575939954.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s575939954", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n val b = (0 until n).map { sc.next().toLong() }\n println(problem2019c(n, a, b))\n}\n\nfun problem2019c(n: Int, a: List, b: List): Int {\n val diff = LongArray(n)\n var plusList = mutableListOf()\n val minusList = mutableListOf()\n for (i in 0 until n) {\n val diffI = a[i] - b[i]\n diff[i] = diffI\n if (diffI > 0) {\n plusList.add(diffI)\n } else if (diffI < 0) {\n minusList.add(diffI)\n }\n }\n if (minusList.isEmpty()) return 0\n if (plusList.sum() < Math.abs(minusList.sum())) return -1\n plusList = plusList.sortedDescending().toMutableList()\n val minusSum = Math.abs(minusList.sum())\n var count = 0\n var p = 0L\n for (i in 0 until plusList.size) {\n p += plusList[i]\n count++\n if (p >= minusSum) break\n }\n return minusList.count() + count\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "sample_input": "3\n2 3 5\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03151", "source_text": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1039, "cpu_time_ms": 865, "memory_kb": 66116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s314654774", "group_id": "codeNet:p03152", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toLong)\n val aSet = readLine()!!.split(' ').map(String::toLong).toSortedSet()\n val bSet = readLine()!!.split(' ').map(String::toLong).toSortedSet()\n if (n.toInt() != aSet.size || m.toInt() != bSet.size) {\n println(0)\n return\n }\n var answer = 1L\n for (i in n * m downTo 1) {\n val aContainsI = aSet.contains(i)\n val bContainsI = bSet.contains(i)\n var aCountLargerI = aSet.indexOfFirst { it >= i }\n var bCountLargerI = bSet.indexOfFirst { it >= i }\n if (aCountLargerI == -1) aCountLargerI = n.toInt()\n if (bCountLargerI == -1) bCountLargerI = m.toInt()\n\n if (aContainsI && bContainsI) {\n //do nothing\n } else if (aContainsI) {\n answer *= m - bCountLargerI\n } else if (bContainsI) {\n answer *= m - aCountLargerI\n } else {\n answer *= (n - aCountLargerI) * (m - bCountLargerI) - (n * m - i)\n }\n answer %= 1000000007\n }\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1547554743, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03152.html", "problem_id": "p03152", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03152/input.txt", "sample_output_relpath": "derived/input_output/data/p03152/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03152/Kotlin/s314654774.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s314654774", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map(String::toLong)\n val aSet = readLine()!!.split(' ').map(String::toLong).toSortedSet()\n val bSet = readLine()!!.split(' ').map(String::toLong).toSortedSet()\n if (n.toInt() != aSet.size || m.toInt() != bSet.size) {\n println(0)\n return\n }\n var answer = 1L\n for (i in n * m downTo 1) {\n val aContainsI = aSet.contains(i)\n val bContainsI = bSet.contains(i)\n var aCountLargerI = aSet.indexOfFirst { it >= i }\n var bCountLargerI = bSet.indexOfFirst { it >= i }\n if (aCountLargerI == -1) aCountLargerI = n.toInt()\n if (bCountLargerI == -1) bCountLargerI = m.toInt()\n\n if (aContainsI && bContainsI) {\n //do nothing\n } else if (aContainsI) {\n answer *= m - bCountLargerI\n } else if (bContainsI) {\n answer *= m - aCountLargerI\n } else {\n answer *= (n - aCountLargerI) * (m - bCountLargerI) - (n * m - i)\n }\n answer %= 1000000007\n }\n println(answer)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nConsider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates.\nTakahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\nThe largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n\nThe largest among the values in the j-th column (1 \\leq j \\leq M) is B_j.\n\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq M \\leq 1000\n\n1 \\leq A_i \\leq N \\times M\n\n1 \\leq B_j \\leq N \\times M\n\nA_i and B_j are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{M}\n\nOutput\n\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n4 3\n3 4\n\nSample Output 1\n\n2\n\n(A_1, A_2) = (4, 3) and (B_1, B_2) = (3, 4). In this case, there are two ways to write the numbers, as follows:\n\n1 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 2 in (2, 2).\n\n2 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 1 in (2, 2).\n\nHere, (i, j) denotes the square at the i-th row and the j-th column.\n\nSample Input 2\n\n3 3\n5 9 7\n3 6 9\n\nSample Output 2\n\n0\n\nSince there is no way to write the numbers under the condition, 0 should be printed.\n\nSample Input 3\n\n2 2\n4 4\n4 4\n\nSample Output 3\n\n0\n\nSample Input 4\n\n14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n\nSample Output 4\n\n343772227", "sample_input": "2 2\n4 3\n3 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03152", "source_text": "Score : 500 points\n\nProblem Statement\n\nConsider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates.\nTakahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\nThe largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n\nThe largest among the values in the j-th column (1 \\leq j \\leq M) is B_j.\n\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq M \\leq 1000\n\n1 \\leq A_i \\leq N \\times M\n\n1 \\leq B_j \\leq N \\times M\n\nA_i and B_j are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{M}\n\nOutput\n\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n4 3\n3 4\n\nSample Output 1\n\n2\n\n(A_1, A_2) = (4, 3) and (B_1, B_2) = (3, 4). In this case, there are two ways to write the numbers, as follows:\n\n1 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 2 in (2, 2).\n\n2 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 1 in (2, 2).\n\nHere, (i, j) denotes the square at the i-th row and the j-th column.\n\nSample Input 2\n\n3 3\n5 9 7\n3 6 9\n\nSample Output 2\n\n0\n\nSince there is no way to write the numbers under the condition, 0 should be printed.\n\nSample Input 3\n\n2 2\n4 4\n4 4\n\nSample Output 3\n\n0\n\nSample Input 4\n\n14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n\nSample Output 4\n\n343772227", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1082, "cpu_time_ms": 474, "memory_kb": 70236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s614513913", "group_id": "codeNet:p03162", "input_text": "import java.lang.Math.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val happiness = Array(n) { IntArray(3) }\n for (i in 0 until n) {\n val tmp = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n happiness[i] = tmp\n }\n\n val dp = Array(n) { IntArray(3) }\n dp[0][0] = happiness[0][0]\n dp[0][1] = happiness[0][1]\n dp[0][2] = happiness[0][2]\n\n for (i in 1 until n) {\n dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + happiness[i][0]\n dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + happiness[i][1]\n dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + happiness[i][2]\n }\n\n println(dp.last().max())\n}", "language": "Kotlin", "metadata": {"date": 1588606642, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/Kotlin/s614513913.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614513913", "user_id": "u531770859"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "import java.lang.Math.*\n\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val happiness = Array(n) { IntArray(3) }\n for (i in 0 until n) {\n val tmp = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n happiness[i] = tmp\n }\n\n val dp = Array(n) { IntArray(3) }\n dp[0][0] = happiness[0][0]\n dp[0][1] = happiness[0][1]\n dp[0][2] = happiness[0][2]\n\n for (i in 1 until n) {\n dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + happiness[i][0]\n dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + happiness[i][1]\n dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + happiness[i][2]\n }\n\n println(dp.last().max())\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 673, "cpu_time_ms": 583, "memory_kb": 80584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s616437394", "group_id": "codeNet:p03162", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val list = Array(N) {\n readLine()!!.split(\" \").map(String::toInt)\n }\n\n val dp = Array(N + 1) { Array(3) { 0 } }\n\n for (i in 0 until N) {\n for (j in 0 until 3) {\n for (k in 0 until 3) {\n if (j == k) {\n continue\n }\n dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][k] + list[i][j])\n }\n }\n }\n\n println(dp[N].max())\n}\n", "language": "Kotlin", "metadata": {"date": 1565941746, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/Kotlin/s616437394.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s616437394", "user_id": "u085288971"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val list = Array(N) {\n readLine()!!.split(\" \").map(String::toInt)\n }\n\n val dp = Array(N + 1) { Array(3) { 0 } }\n\n for (i in 0 until N) {\n for (j in 0 until 3) {\n for (k in 0 until 3) {\n if (j == k) {\n continue\n }\n dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][k] + list[i][j])\n }\n }\n }\n\n println(dp[N].max())\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 850, "memory_kb": 97280}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s712424522", "group_id": "codeNet:p03164", "input_text": "fun main(args: Array) {\n\n var (N,W) = readLine()!!.split(\" \").map{it.toInt()}\n\n var maxVal = 1000001\n\n var dp = Array(101){LongArray(maxVal+1){ Long.MAX_VALUE/2}}\n// var w = LongArray(N)\n// var v = IntArray(N)\n\n// for(i in 0 until N){\n// val(wi,vi) = readLine()!!.split(\" \")\n// w[i] = wi.toLong()\n// v[i] = vi.toInt()\n// }\n\n// for(j in 0..v[0]){\n// dp[0][j] = w[0]\n//\n// }\n var ans = 0\n\n// for(i in 1 until N){\n// for(j in 0..maxVal){\n//\n// if(v[i] >= j) {\n// dp[i][j] = Math.min(dp[i-1][j],w[i])\n// } else {\n// dp[i][j] = Math.min(dp[i-1][j],dp[i-1][j-v[i]] + w[i])\n// }\n//\n//\n//\n// }\n//\n// }\n// for(i in 0 until N){\n// for(j in 0 until maxVal+1){\n// if(dp[i][j] <= W){\n// ans = Math.max(ans,j)\n// }\n// }\n//\n// }\n\n println(ans)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1583533585, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03164/input.txt", "sample_output_relpath": "derived/input_output/data/p03164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03164/Kotlin/s712424522.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s712424522", "user_id": "u579455624"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "fun main(args: Array) {\n\n var (N,W) = readLine()!!.split(\" \").map{it.toInt()}\n\n var maxVal = 1000001\n\n var dp = Array(101){LongArray(maxVal+1){ Long.MAX_VALUE/2}}\n// var w = LongArray(N)\n// var v = IntArray(N)\n\n// for(i in 0 until N){\n// val(wi,vi) = readLine()!!.split(\" \")\n// w[i] = wi.toLong()\n// v[i] = vi.toInt()\n// }\n\n// for(j in 0..v[0]){\n// dp[0][j] = w[0]\n//\n// }\n var ans = 0\n\n// for(i in 1 until N){\n// for(j in 0..maxVal){\n//\n// if(v[i] >= j) {\n// dp[i][j] = Math.min(dp[i-1][j],w[i])\n// } else {\n// dp[i][j] = Math.min(dp[i-1][j],dp[i-1][j-v[i]] + w[i])\n// }\n//\n//\n//\n// }\n//\n// }\n// for(i in 0 until N){\n// for(j in 0 until maxVal+1){\n// if(dp[i][j] <= W){\n// ans = Math.max(ans,j)\n// }\n// }\n//\n// }\n\n println(ans)\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "sample_input": "3 8\n3 30\n4 50\n5 60\n"}, "reference_outputs": ["90\n"], "source_document_id": "p03164", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 941, "cpu_time_ms": 464, "memory_kb": 279052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s892892243", "group_id": "codeNet:p03166", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n\n val graph = Graph1(n)\n repeat(m) {\n val (x, y) = readLine()!!.split(' ').map { it.toInt() }\n graph.add(x - 1, y - 1)\n }\n\n println(graph.solve())\n}\n\nclass Graph1 constructor(private val n: Int) {\n private val graph = Array(n) { mutableListOf() }\n private val dp = IntArray(100000) { -1 }\n\n fun add(x: Int, y: Int) {\n graph[x].add(y)\n }\n\n private fun rec(v: Int): Int {\n if (dp[v] != -1) return dp[v]\n\n var res = 0\n graph[v].forEach {\n res = Math.max(res, rec(it) + 1)\n }\n dp[v] = res\n return res\n }\n\n fun solve(): Int {\n var res = 0\n (0 until n).forEach {\n res = Math.max(res, rec(it))\n }\n return res\n }\n\n}\n\nclass Graph2 constructor(private val n: Int) {\n private val graph = Array(n) { mutableListOf() }\n private val deg = IntArray(n) { 0 }\n private val dp = IntArray(100000) { 0 }\n\n fun add(x: Int, y: Int) {\n graph[x].add(y)\n deg[y]++\n }\n\n fun solve(): Int {\n\n val queue: Queue = ArrayDeque()\n deg.forEachIndexed { index, i ->\n if (i == 0) {\n queue.add(index)\n }\n }\n\n while (queue.isNotEmpty()) {\n val v = queue.remove()\n graph[v].forEach {\n deg[it]--\n if (deg[it] == 0) {\n queue.add(it)\n dp[it] = Math.max(dp[it], dp[v] + 1)\n }\n }\n }\n\n var res = 0\n (0 until n).forEach {\n res = Math.max(res, dp[it])\n }\n return res\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1549195646, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/Kotlin/s892892243.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s892892243", "user_id": "u863309603"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (n, m) = readLine()!!.split(' ').map { it.toInt() }\n\n val graph = Graph1(n)\n repeat(m) {\n val (x, y) = readLine()!!.split(' ').map { it.toInt() }\n graph.add(x - 1, y - 1)\n }\n\n println(graph.solve())\n}\n\nclass Graph1 constructor(private val n: Int) {\n private val graph = Array(n) { mutableListOf() }\n private val dp = IntArray(100000) { -1 }\n\n fun add(x: Int, y: Int) {\n graph[x].add(y)\n }\n\n private fun rec(v: Int): Int {\n if (dp[v] != -1) return dp[v]\n\n var res = 0\n graph[v].forEach {\n res = Math.max(res, rec(it) + 1)\n }\n dp[v] = res\n return res\n }\n\n fun solve(): Int {\n var res = 0\n (0 until n).forEach {\n res = Math.max(res, rec(it))\n }\n return res\n }\n\n}\n\nclass Graph2 constructor(private val n: Int) {\n private val graph = Array(n) { mutableListOf() }\n private val deg = IntArray(n) { 0 }\n private val dp = IntArray(100000) { 0 }\n\n fun add(x: Int, y: Int) {\n graph[x].add(y)\n deg[y]++\n }\n\n fun solve(): Int {\n\n val queue: Queue = ArrayDeque()\n deg.forEachIndexed { index, i ->\n if (i == 0) {\n queue.add(index)\n }\n }\n\n while (queue.isNotEmpty()) {\n val v = queue.remove()\n graph[v].forEach {\n deg[it]--\n if (deg[it] == 0) {\n queue.add(it)\n dp[it] = Math.max(dp[it], dp[v] + 1)\n }\n }\n }\n\n var res = 0\n (0 until n).forEach {\n res = Math.max(res, dp[it])\n }\n return res\n }\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1768, "cpu_time_ms": 678, "memory_kb": 71444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s131537812", "group_id": "codeNet:p03171", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\tval n = readLine()!!.toInt()\n\tval s = readLine()!!.trim().split(' ').map{ x -> x.toInt() }\n\n\tvar dp = Array(n) { Array(n) { 0 } }\n\n\tfor (i in 0..n - 1) {\n\t\tdp[i][i] = s[i]\n\t}\n\n\tfor (i in (n - 2) downTo 0) {\n\t\tfor (j in (i + 1) .. (n - 1)) {\n\t\t\tvar a = s[i] - dp[i + 1][j]\n\t\t\tvar b = s[j] - dp[i][j - 1]\n\t\t\tdp[i][j] = if (a > b) a else b\n\t\t}\n\t}\n\n\tprintln(dp[0][n - 1])\n}", "language": "Kotlin", "metadata": {"date": 1565027612, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03171.html", "problem_id": "p03171", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03171/input.txt", "sample_output_relpath": "derived/input_output/data/p03171/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03171/Kotlin/s131537812.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s131537812", "user_id": "u874414087"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\tval n = readLine()!!.toInt()\n\tval s = readLine()!!.trim().split(' ').map{ x -> x.toInt() }\n\n\tvar dp = Array(n) { Array(n) { 0 } }\n\n\tfor (i in 0..n - 1) {\n\t\tdp[i][i] = s[i]\n\t}\n\n\tfor (i in (n - 2) downTo 0) {\n\t\tfor (j in (i + 1) .. (n - 1)) {\n\t\t\tvar a = s[i] - dp[i + 1][j]\n\t\t\tvar b = s[j] - dp[i][j - 1]\n\t\t\tdp[i][j] = if (a > b) a else b\n\t\t}\n\t}\n\n\tprintln(dp[0][n - 1])\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N).\nUntil a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\nRemove the element at the beginning or the end of a. The player earns x points, where x is the removed element.\n\nLet X and Y be Taro's and Jiro's total score at the end of the game, respectively.\nTaro tries to maximize X - Y, while Jiro tries to minimize X - Y.\n\nAssuming that the two players play optimally, find the resulting value of X - Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the resulting value of X - Y, assuming that the two players play optimally.\n\nSample Input 1\n\n4\n10 80 90 30\n\nSample Output 1\n\n10\n\nThe game proceeds as follows when the two players play optimally (the element being removed is written bold):\n\nTaro: (10, 80, 90, 30) → (10, 80, 90)\n\nJiro: (10, 80, 90) → (10, 80)\n\nTaro: (10, 80) → (10)\n\nJiro: (10) → ()\n\nHere, X = 30 + 80 = 110 and Y = 90 + 10 = 100.\n\nSample Input 2\n\n3\n10 100 10\n\nSample Output 2\n\n-80\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (10, 100, 10) → (100, 10)\n\nJiro: (100, 10) → (10)\n\nTaro: (10) → ()\n\nHere, X = 10 + 10 = 20 and Y = 100.\n\nSample Input 3\n\n1\n10\n\nSample Output 3\n\n10\n\nSample Input 4\n\n10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n\nSample Output 4\n\n4999999995\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 5\n\n6\n4 2 9 7 1 5\n\nSample Output 5\n\n2\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (4, 2, 9, 7, 1, 5) → (4, 2, 9, 7, 1)\n\nJiro: (4, 2, 9, 7, 1) → (2, 9, 7, 1)\n\nTaro: (2, 9, 7, 1) → (2, 9, 7)\n\nJiro: (2, 9, 7) → (2, 9)\n\nTaro: (2, 9) → (2)\n\nJiro: (2) → ()\n\nHere, X = 5 + 1 + 9 = 15 and Y = 4 + 7 + 2 = 13.", "sample_input": "4\n10 80 90 30\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03171", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N).\nUntil a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\nRemove the element at the beginning or the end of a. The player earns x points, where x is the removed element.\n\nLet X and Y be Taro's and Jiro's total score at the end of the game, respectively.\nTaro tries to maximize X - Y, while Jiro tries to minimize X - Y.\n\nAssuming that the two players play optimally, find the resulting value of X - Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the resulting value of X - Y, assuming that the two players play optimally.\n\nSample Input 1\n\n4\n10 80 90 30\n\nSample Output 1\n\n10\n\nThe game proceeds as follows when the two players play optimally (the element being removed is written bold):\n\nTaro: (10, 80, 90, 30) → (10, 80, 90)\n\nJiro: (10, 80, 90) → (10, 80)\n\nTaro: (10, 80) → (10)\n\nJiro: (10) → ()\n\nHere, X = 30 + 80 = 110 and Y = 90 + 10 = 100.\n\nSample Input 2\n\n3\n10 100 10\n\nSample Output 2\n\n-80\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (10, 100, 10) → (100, 10)\n\nJiro: (100, 10) → (10)\n\nTaro: (10) → ()\n\nHere, X = 10 + 10 = 20 and Y = 100.\n\nSample Input 3\n\n1\n10\n\nSample Output 3\n\n10\n\nSample Input 4\n\n10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n\nSample Output 4\n\n4999999995\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 5\n\n6\n4 2 9 7 1 5\n\nSample Output 5\n\n2\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (4, 2, 9, 7, 1, 5) → (4, 2, 9, 7, 1)\n\nJiro: (4, 2, 9, 7, 1) → (2, 9, 7, 1)\n\nTaro: (2, 9, 7, 1) → (2, 9, 7)\n\nJiro: (2, 9, 7) → (2, 9)\n\nTaro: (2, 9) → (2)\n\nJiro: (2) → ()\n\nHere, X = 5 + 1 + 9 = 15 and Y = 4 + 7 + 2 = 13.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 422, "cpu_time_ms": 2119, "memory_kb": 188196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s711415982", "group_id": "codeNet:p03186", "input_text": "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 println(if (a + b < c) a + 2 * b + 1 else b + c)\n}", "language": "Kotlin", "metadata": {"date": 1546444066, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03186.html", "problem_id": "p03186", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03186/input.txt", "sample_output_relpath": "derived/input_output/data/p03186/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03186/Kotlin/s711415982.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711415982", "user_id": "u429443682"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "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 println(if (a + b < c) a + 2 * b + 1 else b + c)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "sample_input": "3 1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03186", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 184, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s685262106", "group_id": "codeNet:p03196", "input_text": "fun main(args : Array) {\n val (n, p) = readLine()!!.split(\" \").map { it.toLong() }\n val divisors = decom(p)\n\n var current = p\n var factors = mutableMapOf()\n divisors.forEach {\n while (current != 1L && current % it == 0L) {\n current /= it\n factors[it] = (factors[it] ?: 0L) + 1L\n }\n }\n factors[current] = 1L\n\n var ans = 1L\n factors.forEach {\n if (it.value >= n) {\n ans *= Math.pow(it.key.toDouble(), (it.value / n).toDouble()).toLong()\n }\n }\n\n println(ans)\n}\n\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n", "language": "Kotlin", "metadata": {"date": 1582110638, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03196/input.txt", "sample_output_relpath": "derived/input_output/data/p03196/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03196/Kotlin/s685262106.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s685262106", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, p) = readLine()!!.split(\" \").map { it.toLong() }\n val divisors = decom(p)\n\n var current = p\n var factors = mutableMapOf()\n divisors.forEach {\n while (current != 1L && current % it == 0L) {\n current /= it\n factors[it] = (factors[it] ?: 0L) + 1L\n }\n }\n factors[current] = 1L\n\n var ans = 1L\n factors.forEach {\n if (it.value >= n) {\n ans *= Math.pow(it.key.toDouble(), (it.value / n).toDouble()).toLong()\n }\n }\n\n println(ans)\n}\n\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03196", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 950, "cpu_time_ms": 1197, "memory_kb": 52808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s486173200", "group_id": "codeNet:p03197", "input_text": "fun main(args: Array) {\n caddi2018d()\n}\n\nfun caddi2018d() {\n val n = readLine()!!.toInt()\n val aList = (1..n).map { readLine()!!.toInt() }\n\n val answer = if (aList.all { it % 2 == 0 }) \"second\" else \"first\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1576206531, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03197.html", "problem_id": "p03197", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03197/input.txt", "sample_output_relpath": "derived/input_output/data/p03197/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03197/Kotlin/s486173200.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s486173200", "user_id": "u139478771"}, "prompt_components": {"gold_output": "first\n", "input_to_evaluate": "fun main(args: Array) {\n caddi2018d()\n}\n\nfun caddi2018d() {\n val n = readLine()!!.toInt()\n val aList = (1..n).map { readLine()!!.toInt() }\n\n val answer = if (aList.all { it % 2 == 0 }) \"second\" else \"first\"\n\n println(answer)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "sample_input": "2\n1\n2\n"}, "reference_outputs": ["first\n"], "source_document_id": "p03197", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 250, "cpu_time_ms": 323, "memory_kb": 38956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s441340997", "group_id": "codeNet:p03200", "input_text": "fun main(args: Array){\n val s = readLine()!!\n var ans = 0\n var wCnt = 0\n for (i in 0 until s.length) {\n if (s[i] == 'W') {\n ans += i - wCnt\n wCnt++\n }\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1562015367, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03200/input.txt", "sample_output_relpath": "derived/input_output/data/p03200/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03200/Kotlin/s441340997.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s441340997", "user_id": "u712822150"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val s = readLine()!!\n var ans = 0\n var wCnt = 0\n for (i in 0 until s.length) {\n if (s[i] == 'W') {\n ans += i - wCnt\n wCnt++\n }\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "sample_input": "BBW\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03200", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 247, "memory_kb": 33748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s446948339", "group_id": "codeNet:p03208", "input_text": "fun main(args : Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val hh = IntArray(n){ Integer.parseInt(readLine()!!) }\n hh.sort()\n\n var min = Int.MAX_VALUE\n\n for (i in 0..n-k) {\n val diff = hh[i+k-1] - hh[i]\n if (diff < min) min = diff\n }\n\n println(min)\n}", "language": "Kotlin", "metadata": {"date": 1571741017, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Kotlin/s446948339.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s446948339", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val hh = IntArray(n){ Integer.parseInt(readLine()!!) }\n hh.sort()\n\n var min = Int.MAX_VALUE\n\n for (i in 0..n-k) {\n val diff = hh[i+k-1] - hh[i]\n if (diff < min) min = diff\n }\n\n println(min)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 447, "memory_kb": 42996}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s013782089", "group_id": "codeNet:p03208", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (N, K) = readInputLine().split(\" \").map{it.toInt()}\n \n val hs = IntArray(N)\n \n for (i in 0 until N) {\n hs[i] = readInputLine().toInt()\n }\n \n hs.sort()\n \n println(Math.min(hs[K - 1] - hs[0], hs[N - 1] - hs[N - 1 - K + 1]))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565447277, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Kotlin/s013782089.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s013782089", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (N, K) = readInputLine().split(\" \").map{it.toInt()}\n \n val hs = IntArray(N)\n \n for (i in 0 until N) {\n hs[i] = readInputLine().toInt()\n }\n \n hs.sort()\n \n println(Math.min(hs[K - 1] - hs[0], hs[N - 1] - hs[N - 1 - K + 1]))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 433, "memory_kb": 43328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s521102770", "group_id": "codeNet:p03209", "input_text": "fun main(args: Array) {\n val (N, X) = readLine()!!.split(\" \").map{it.toLong()}\n\n val t = Array(60) { 0L }\n val p = Array(60) { 0L }\n\n t[0] = 1\n p[0] = 1\n for (i in 1 until t.size) {\n t[i] = t[i - 1] * 2 + 3\n p[i] = p[i - 1] * 2 + 1\n }\n\n fun rec(n: Int, x: Long): Long {\n if (t[n] <= x) {\n return p[n]\n }\n\n if (n == 0) {\n return 0L\n }\n\n var r = 0L\n\n if (x < t[n - 1] + 1) {\n r += rec(n - 1, x - 1)\n }\n\n if (x >= t[n - 1] + 1) {\n r += p[n - 1]\n }\n\n if (x >= t[n - 1] + 2) {\n r += 1L\n }\n\n if (x > t[n - 1] + 2) {\n r += rec(n - 1, x - t[n - 1] - 2)\n }\n\n return r\n }\n\n println(rec(N.toInt(), X))\n}\n", "language": "Kotlin", "metadata": {"date": 1579239222, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03209.html", "problem_id": "p03209", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03209/input.txt", "sample_output_relpath": "derived/input_output/data/p03209/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03209/Kotlin/s521102770.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s521102770", "user_id": "u183530284"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, X) = readLine()!!.split(\" \").map{it.toLong()}\n\n val t = Array(60) { 0L }\n val p = Array(60) { 0L }\n\n t[0] = 1\n p[0] = 1\n for (i in 1 until t.size) {\n t[i] = t[i - 1] * 2 + 3\n p[i] = p[i - 1] * 2 + 1\n }\n\n fun rec(n: Int, x: Long): Long {\n if (t[n] <= x) {\n return p[n]\n }\n\n if (n == 0) {\n return 0L\n }\n\n var r = 0L\n\n if (x < t[n - 1] + 1) {\n r += rec(n - 1, x - 1)\n }\n\n if (x >= t[n - 1] + 1) {\n r += p[n - 1]\n }\n\n if (x >= t[n - 1] + 2) {\n r += 1L\n }\n\n if (x > t[n - 1] + 2) {\n r += rec(n - 1, x - t[n - 1] - 2)\n }\n\n return r\n }\n\n println(rec(N.toInt(), X))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "sample_input": "2 7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03209", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 809, "cpu_time_ms": 240, "memory_kb": 38044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s863823182", "group_id": "codeNet:p03210", "input_text": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n\n println(if (listOf(3, 5, 7).any { it == x }) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1564450363, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03210/input.txt", "sample_output_relpath": "derived/input_output/data/p03210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03210/Kotlin/s863823182.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s863823182", "user_id": "u108272327"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n\n println(if (listOf(3, 5, 7).any { it == x }) \"YES\" else \"NO\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 221, "memory_kb": 34012}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s024581396", "group_id": "codeNet:p03210", "input_text": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n val message = if (x == 3 || x == 5 || x == 7) \"YES\" else \"NO\"\n println(message)\n}\n", "language": "Kotlin", "metadata": {"date": 1545108808, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03210/input.txt", "sample_output_relpath": "derived/input_output/data/p03210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03210/Kotlin/s024581396.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s024581396", "user_id": "u051841332"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val x = readLine()!!.toInt()\n val message = if (x == 3 || x == 5 || x == 7) \"YES\" else \"NO\"\n println(message)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 207, "memory_kb": 29788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s804552720", "group_id": "codeNet:p03211", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(problem114b(s))\n}\n\nfun problem114b(s: String): Int {\n var min = Integer.MAX_VALUE\n for (i in 0 until s.length - 2) {\n val si = (s[i].toString() + s[i+1] + s[i+2]).toInt()\n min = Math.min(min, Math.abs(si - 753))\n }\n return min\n}", "language": "Kotlin", "metadata": {"date": 1588690609, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03211/input.txt", "sample_output_relpath": "derived/input_output/data/p03211/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03211/Kotlin/s804552720.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s804552720", "user_id": "u073232808"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n println(problem114b(s))\n}\n\nfun problem114b(s: String): Int {\n var min = Integer.MAX_VALUE\n for (i in 0 until s.length - 2) {\n val si = (s[i].toString() + s[i+1] + s[i+2]).toInt()\n min = Math.min(min, Math.abs(si - 753))\n }\n return min\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 374, "cpu_time_ms": 188, "memory_kb": 31272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s331611131", "group_id": "codeNet:p03211", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n var min = Integer.MAX_VALUE\n for (i in 0..(s.length - 3)) {\n min = Math.min(min, Math.abs(s.substring(i, i + 3).toInt()-753))\n }\n print(min)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1543802654, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03211/input.txt", "sample_output_relpath": "derived/input_output/data/p03211/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03211/Kotlin/s331611131.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331611131", "user_id": "u099066216"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n var min = Integer.MAX_VALUE\n for (i in 0..(s.length - 3)) {\n min = Math.min(min, Math.abs(s.substring(i, i + 3).toInt()-753))\n }\n print(min)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 203, "memory_kb": 29872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s556015956", "group_id": "codeNet:p03212", "input_text": "// https://atcoder.jp/contests/abc114/tasks/abc114_c\n// TODO: refactoring\n\nfun main() {\n abc114c()\n}\n\nfun abc114c() {\n val n = readLine()!!\n if (n.toLong() < 357L) {\n // 3,5,7がすくなくとも1つずつ必要なので、最低値は357\n println(0)\n return\n }\n // 3,5,7の組み合わせだが、それぞれ1個以上ないといけないのが地味にきく\n // たとえば337とかは5がないのでダメ\n // N=1000の場合は6になる(357,375,537,573,735,753の6つ)\n // N=4000だと3桁は上記パターンのみ、4桁の数字だと4桁目に3が使えるようになるので、\n // 任意の1桁に3,5,7が自由に使えるようになる。これがややこしい\n // 最大でも10桁、かつ各桁3個の数字しかないので、全組み合わせでやればいいんじゃないだろうか\n // 解けたけど、こんなくそややこしいロジックより良い方法あるんちゃうの?\n // ただ解説を見た限り、考え方としてはこのやり方は悪くないらしい\n // 実装はよくなさそう\n val v = NanaGoSan(n)\n var count = 0\n while (v.increment()) {\n if (v.isSatisfy()) count++\n }\n println(count)\n}\n\nprivate class NanaGoSan(val origin: String) {\n val digits: Int\n val maxValue: IntArray\n val originValue: IntArray\n val currentValue: IntArray\n \n init {\n digits = origin.length\n maxValue = IntArray(digits)\n originValue = IntArray(digits)\n currentValue = IntArray(digits) { 0 }\n var n = origin.toLong()\n for (i in 0 until digits) {\n val t = n % 10\n originValue[i] = t.toInt()\n val v = when (t) {\n in 3..4 -> 1\n in 5..6 -> 2\n in 7..9 -> 3\n else -> 0\n }\n n /= 10\n maxValue[i] = v\n }\n var i = digits - 1\n var update = false\n while (i >= 0) {\n if (update) {\n maxValue[i] = 3\n } else {\n if (originValue[i] !in setOf(3, 5, 7)) update = true\n }\n i--\n }\n }\n \n fun increment(i: Int = 0): Boolean {\n if (!lessThanLimit()) return false\n if (i >= digits) return false\n if (currentValue[i] == 3) {\n currentValue[i] = 1\n return increment(i + 1)\n }\n currentValue[i]++\n return true\n }\n \n fun isSatisfy(): Boolean {\n if (!lessThanLimit()) return false\n var one = 0\n var two = 0\n var three = 0\n for (i in digits - 1 downTo 0) {\n when (currentValue[i]) {\n 1 -> one++\n 2 -> two++\n 3 -> three++\n else -> Unit\n }\n if (one > 0 && two > 0 && three > 0) return true\n }\n return false\n }\n \n private fun lessThanLimit(): Boolean {\n for (i in digits - 1 downTo 0) {\n if (currentValue[i] < maxValue[i]) return true\n if (currentValue[i] > maxValue[i]) return false\n }\n return true\n }\n}", "language": "Kotlin", "metadata": {"date": 1594872267, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03212.html", "problem_id": "p03212", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03212/input.txt", "sample_output_relpath": "derived/input_output/data/p03212/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03212/Kotlin/s556015956.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s556015956", "user_id": "u628907033"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "// https://atcoder.jp/contests/abc114/tasks/abc114_c\n// TODO: refactoring\n\nfun main() {\n abc114c()\n}\n\nfun abc114c() {\n val n = readLine()!!\n if (n.toLong() < 357L) {\n // 3,5,7がすくなくとも1つずつ必要なので、最低値は357\n println(0)\n return\n }\n // 3,5,7の組み合わせだが、それぞれ1個以上ないといけないのが地味にきく\n // たとえば337とかは5がないのでダメ\n // N=1000の場合は6になる(357,375,537,573,735,753の6つ)\n // N=4000だと3桁は上記パターンのみ、4桁の数字だと4桁目に3が使えるようになるので、\n // 任意の1桁に3,5,7が自由に使えるようになる。これがややこしい\n // 最大でも10桁、かつ各桁3個の数字しかないので、全組み合わせでやればいいんじゃないだろうか\n // 解けたけど、こんなくそややこしいロジックより良い方法あるんちゃうの?\n // ただ解説を見た限り、考え方としてはこのやり方は悪くないらしい\n // 実装はよくなさそう\n val v = NanaGoSan(n)\n var count = 0\n while (v.increment()) {\n if (v.isSatisfy()) count++\n }\n println(count)\n}\n\nprivate class NanaGoSan(val origin: String) {\n val digits: Int\n val maxValue: IntArray\n val originValue: IntArray\n val currentValue: IntArray\n \n init {\n digits = origin.length\n maxValue = IntArray(digits)\n originValue = IntArray(digits)\n currentValue = IntArray(digits) { 0 }\n var n = origin.toLong()\n for (i in 0 until digits) {\n val t = n % 10\n originValue[i] = t.toInt()\n val v = when (t) {\n in 3..4 -> 1\n in 5..6 -> 2\n in 7..9 -> 3\n else -> 0\n }\n n /= 10\n maxValue[i] = v\n }\n var i = digits - 1\n var update = false\n while (i >= 0) {\n if (update) {\n maxValue[i] = 3\n } else {\n if (originValue[i] !in setOf(3, 5, 7)) update = true\n }\n i--\n }\n }\n \n fun increment(i: Int = 0): Boolean {\n if (!lessThanLimit()) return false\n if (i >= digits) return false\n if (currentValue[i] == 3) {\n currentValue[i] = 1\n return increment(i + 1)\n }\n currentValue[i]++\n return true\n }\n \n fun isSatisfy(): Boolean {\n if (!lessThanLimit()) return false\n var one = 0\n var two = 0\n var three = 0\n for (i in digits - 1 downTo 0) {\n when (currentValue[i]) {\n 1 -> one++\n 2 -> two++\n 3 -> three++\n else -> Unit\n }\n if (one > 0 && two > 0 && three > 0) return true\n }\n return false\n }\n \n private fun lessThanLimit(): Boolean {\n for (i in digits - 1 downTo 0) {\n if (currentValue[i] < maxValue[i]) return true\n if (currentValue[i] > maxValue[i]) return false\n }\n return true\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "sample_input": "575\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03212", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3178, "cpu_time_ms": 133, "memory_kb": 39188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s113357090", "group_id": "codeNet:p03215", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val (N,K) = rd.readListInt()\n val A = rd.readListLong()\n\n val ms = mutableSetOf()\n for (i in 0 until N-1) {\n var sum = A[i]\n ms.add(sum)\n for (j in i+1 until N) {\n sum += A[j]\n ms.add(sum)\n }\n }\n\n val bt = ms.toList()\n val M = bt.size\n val B = Array(M){\"\"}\n for (i in 0 until M) {\n B[i] = bt[i].toString(2).padStart(64, '0')\n }\n\n val RB = Array(64){IntArray(M)}\n for (i in 0 until M) {\n for (d in 0 until 64) {\n RB[d][i] = B[i][d] - '0'\n }\n }\n\n val take = RB.map{it.count{it>0} >= K}\n\n val range = RB.map{\n it.mapIndexed{i,v ->\n if (v>0) i else -1}\n .filter { it>=0 }.toMutableSet()\n }\n\n val res = Array(64){mutableSetOf()}\n var pd = -1\n for (d in 0 until 64) {\n if (take[d]) {\n if (pd < 0) {\n res[d] = range[d]\n pd = d\n } else {\n val prod = res[pd].intersect(range[d])\n if (prod.size >= K) {\n res[d].addAll(prod)\n pd = d\n }\n }\n }\n }\n\n var ans = 0L\n for (d in 0 until 64) {\n if (res[d].size >=K) {\n ans += 1L shl (63-d)\n }\n }\n\n println(ans)\n\n return\n}\n\n\n//val rd = debug.Reader(\"etc\", \"dwacon5th-prelims\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readDouble: () -> Double = { br.readLine().toDouble() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntArray: () -> IntArray = { readListInt().toIntArray() }\n val readLongArray: () -> LongArray = { readListLong().toLongArray() }\n val readListStringCol: (Int) -> List = { N -> (0 until N).map { readString() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { readListInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { readListLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1600922068, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03215.html", "problem_id": "p03215", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03215/input.txt", "sample_output_relpath": "derived/input_output/data/p03215/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03215/Kotlin/s113357090.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s113357090", "user_id": "u404244809"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val (N,K) = rd.readListInt()\n val A = rd.readListLong()\n\n val ms = mutableSetOf()\n for (i in 0 until N-1) {\n var sum = A[i]\n ms.add(sum)\n for (j in i+1 until N) {\n sum += A[j]\n ms.add(sum)\n }\n }\n\n val bt = ms.toList()\n val M = bt.size\n val B = Array(M){\"\"}\n for (i in 0 until M) {\n B[i] = bt[i].toString(2).padStart(64, '0')\n }\n\n val RB = Array(64){IntArray(M)}\n for (i in 0 until M) {\n for (d in 0 until 64) {\n RB[d][i] = B[i][d] - '0'\n }\n }\n\n val take = RB.map{it.count{it>0} >= K}\n\n val range = RB.map{\n it.mapIndexed{i,v ->\n if (v>0) i else -1}\n .filter { it>=0 }.toMutableSet()\n }\n\n val res = Array(64){mutableSetOf()}\n var pd = -1\n for (d in 0 until 64) {\n if (take[d]) {\n if (pd < 0) {\n res[d] = range[d]\n pd = d\n } else {\n val prod = res[pd].intersect(range[d])\n if (prod.size >= K) {\n res[d].addAll(prod)\n pd = d\n }\n }\n }\n }\n\n var ans = 0L\n for (d in 0 until 64) {\n if (res[d].size >=K) {\n ans += 1L shl (63-d)\n }\n }\n\n println(ans)\n\n return\n}\n\n\n//val rd = debug.Reader(\"etc\", \"dwacon5th-prelims\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\nconst val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\ndata class To(val idx: Int, val cost: Long)\ntypealias ALI = ArrayList\nfun edge(V: Int): Array> { return Array(V){ArrayList()} }\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readDouble: () -> Double = { br.readLine().toDouble() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntArray: () -> IntArray = { readListInt().toIntArray() }\n val readLongArray: () -> LongArray = { readListLong().toLongArray() }\n val readListStringCol: (Int) -> List = { N -> (0 until N).map { readString() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListIntCols: (Int) -> List> = { N -> (0 until N).map { readListInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val readListLongCols: (Int) -> List> = { N -> (0 until N).map { readListLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N.\nHe is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.)\n\nFind the maximum possible value for him.\n\nConstraints\n\n2 \\leq N \\leq 1000\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq K \\leq N(N+1)/2\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n2 5 2 5\n\nSample Output 1\n\n12\n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\ncontiguous subsequences starting from the first element: \\{2\\}, \\{2, 5\\}, \\{2, 5, 2\\}, \\{2, 5, 2, 5\\}\n\ncontiguous subsequences starting from the second element: \\{5\\}, \\{5, 2\\}, \\{5, 2, 5\\}\n\ncontiguous subsequences starting from the third element: \\{2\\}, \\{2, 5\\}\n\ncontiguous subsequences starting from the fourth element: \\{5\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that have different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous subsequences is 12.\nThis can be achieved by choosing \\{5, 2, 5\\} (with beauty 12) and \\{2, 5, 2, 5\\} (with beauty 14).\n\nSample Input 2\n\n8 4\n9 1 8 2 7 5 6 4\n\nSample Output 2\n\n32", "sample_input": "4 2\n2 5 2 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03215", "source_text": "Score : 400 points\n\nProblem Statement\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N.\nHe is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.)\n\nFind the maximum possible value for him.\n\nConstraints\n\n2 \\leq N \\leq 1000\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq K \\leq N(N+1)/2\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n2 5 2 5\n\nSample Output 1\n\n12\n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\ncontiguous subsequences starting from the first element: \\{2\\}, \\{2, 5\\}, \\{2, 5, 2\\}, \\{2, 5, 2, 5\\}\n\ncontiguous subsequences starting from the second element: \\{5\\}, \\{5, 2\\}, \\{5, 2, 5\\}\n\ncontiguous subsequences starting from the third element: \\{2\\}, \\{2, 5\\}\n\ncontiguous subsequences starting from the fourth element: \\{5\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that have different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous subsequences is 12.\nThis can be achieved by choosing \\{5, 2, 5\\} (with beauty 12) and \\{2, 5, 2, 5\\} (with beauty 14).\n\nSample Input 2\n\n8 4\n9 1 8 2 7 5 6 4\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3959, "cpu_time_ms": 2803, "memory_kb": 717236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s985198009", "group_id": "codeNet:p03215", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n// Global\n\nfun solve() {\n val n = nextLong()\n val k = nextLong()\n val a = nextLongAry(n)\n val list = longList()\n for (i in 0 until n) {\n var sum = 0L\n for (j in i until n) {\n sum += a[j]\n list.add(sum)\n }\n }\n\n val flag = boolAry(list.siz, true)\n for (i in 63 downTo 0) {\n val tmpFlag = boolAry(list.siz)\n var count = 0L\n for (j in list.indices) {\n if(!flag[j]) continue\n if(((list[j] shr i) and 1) == 1L) {\n tmpFlag[j] = true\n count++\n }\n }\n if(count >= k) {\n for (j in list.indices) {\n if(!tmpFlag[j]) flag[j] = false\n }\n }\n }\n\n var hoge = true\n var ans = 0L\n for (i in list.indices) {\n if(!flag[i]) continue\n if(hoge) {\n ans = list[i]\n hoge = false\n } else {\n ans = ans and list[i]\n }\n }\n\n println(ans)\n\n}\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextLongs() = readLine()!!.split(\" \").map { it.toLong() }\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1590404844, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03215.html", "problem_id": "p03215", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03215/input.txt", "sample_output_relpath": "derived/input_output/data/p03215/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03215/Kotlin/s985198009.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s985198009", "user_id": "u581625805"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n// Global\n\nfun solve() {\n val n = nextLong()\n val k = nextLong()\n val a = nextLongAry(n)\n val list = longList()\n for (i in 0 until n) {\n var sum = 0L\n for (j in i until n) {\n sum += a[j]\n list.add(sum)\n }\n }\n\n val flag = boolAry(list.siz, true)\n for (i in 63 downTo 0) {\n val tmpFlag = boolAry(list.siz)\n var count = 0L\n for (j in list.indices) {\n if(!flag[j]) continue\n if(((list[j] shr i) and 1) == 1L) {\n tmpFlag[j] = true\n count++\n }\n }\n if(count >= k) {\n for (j in list.indices) {\n if(!tmpFlag[j]) flag[j] = false\n }\n }\n }\n\n var hoge = true\n var ans = 0L\n for (i in list.indices) {\n if(!flag[i]) continue\n if(hoge) {\n ans = list[i]\n hoge = false\n } else {\n ans = ans and list[i]\n }\n }\n\n println(ans)\n\n}\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextLongs() = readLine()!!.split(\" \").map { it.toLong() }\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N.\nHe is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.)\n\nFind the maximum possible value for him.\n\nConstraints\n\n2 \\leq N \\leq 1000\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq K \\leq N(N+1)/2\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n2 5 2 5\n\nSample Output 1\n\n12\n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\ncontiguous subsequences starting from the first element: \\{2\\}, \\{2, 5\\}, \\{2, 5, 2\\}, \\{2, 5, 2, 5\\}\n\ncontiguous subsequences starting from the second element: \\{5\\}, \\{5, 2\\}, \\{5, 2, 5\\}\n\ncontiguous subsequences starting from the third element: \\{2\\}, \\{2, 5\\}\n\ncontiguous subsequences starting from the fourth element: \\{5\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that have different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous subsequences is 12.\nThis can be achieved by choosing \\{5, 2, 5\\} (with beauty 12) and \\{2, 5, 2, 5\\} (with beauty 14).\n\nSample Input 2\n\n8 4\n9 1 8 2 7 5 6 4\n\nSample Output 2\n\n32", "sample_input": "4 2\n2 5 2 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03215", "source_text": "Score : 400 points\n\nProblem Statement\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N.\nHe is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.)\n\nFind the maximum possible value for him.\n\nConstraints\n\n2 \\leq N \\leq 1000\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq K \\leq N(N+1)/2\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n2 5 2 5\n\nSample Output 1\n\n12\n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\ncontiguous subsequences starting from the first element: \\{2\\}, \\{2, 5\\}, \\{2, 5, 2\\}, \\{2, 5, 2, 5\\}\n\ncontiguous subsequences starting from the second element: \\{5\\}, \\{5, 2\\}, \\{5, 2, 5\\}\n\ncontiguous subsequences starting from the third element: \\{2\\}, \\{2, 5\\}\n\ncontiguous subsequences starting from the fourth element: \\{5\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that have different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous subsequences is 12.\nThis can be achieved by choosing \\{5, 2, 5\\} (with beauty 12) and \\{2, 5, 2, 5\\} (with beauty 14).\n\nSample Input 2\n\n8 4\n9 1 8 2 7 5 6 4\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 18579, "cpu_time_ms": 669, "memory_kb": 92244}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s583200811", "group_id": "codeNet:p03219", "input_text": "fun main(args :Array) {\n val (x, y) = readIntegerList()\n println(x + y / 2)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1577044876, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/Kotlin/s583200811.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s583200811", "user_id": "u784448849"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "fun main(args :Array) {\n val (x, y) = readIntegerList()\n println(x + y / 2)\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 299, "cpu_time_ms": 240, "memory_kb": 37868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s178012025", "group_id": "codeNet:p03220", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val t = sc.nextInt()\n val a = sc.nextInt()\n val h = (0 until n).map { sc.next().toInt() }\n println(problem113b(n, t, a, h))\n}\n\nfun problem113b(n: Int, t: Int, a: Int, h: List): Int {\n var tmp = Double.MAX_VALUE\n var ans = 0\n for (i in 0 until n) {\n val temple = t - h[i] * 0.006\n val new = Math.abs(a - temple)\n if(tmp > new) {\n ans = i + 1\n }\n tmp = Math.min(tmp, new)\n }\n return ans\n}", "language": "Kotlin", "metadata": {"date": 1567959129, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/Kotlin/s178012025.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s178012025", "user_id": "u073232808"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val t = sc.nextInt()\n val a = sc.nextInt()\n val h = (0 until n).map { sc.next().toInt() }\n println(problem113b(n, t, a, h))\n}\n\nfun problem113b(n: Int, t: Int, a: Int, h: List): Int {\n var tmp = Double.MAX_VALUE\n var ans = 0\n for (i in 0 until n) {\n val temple = t - h[i] * 0.006\n val new = Math.abs(a - temple)\n if(tmp > new) {\n ans = i + 1\n }\n tmp = Math.min(tmp, new)\n }\n return ans\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 576, "cpu_time_ms": 226, "memory_kb": 31388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s751340544", "group_id": "codeNet:p03220", "input_text": "fun main(args: Array) {\n abc113b()\n}\n\nfun abc113b() {\n val n = readLine()!!.toInt()\n val (t, a) = readLine()!!.split(\" \").map { it.toDouble() }\n val hList = readLine()!!.split(\" \").mapIndexed { index, s -> Pair(index + 1, s.toDouble()) }\n\n val answer = hList.map { Pair(it.first, Math.abs(t - (it.second * 0.006) - a)) }\n .minBy { it.second }?.first\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1566266401, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/Kotlin/s751340544.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s751340544", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n abc113b()\n}\n\nfun abc113b() {\n val n = readLine()!!.toInt()\n val (t, a) = readLine()!!.split(\" \").map { it.toDouble() }\n val hList = readLine()!!.split(\" \").mapIndexed { index, s -> Pair(index + 1, s.toDouble()) }\n\n val answer = hList.map { Pair(it.first, Math.abs(t - (it.second * 0.006) - a)) }\n .minBy { it.second }?.first\n\n println(answer)\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 403, "cpu_time_ms": 252, "memory_kb": 37904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s982675116", "group_id": "codeNet:p03221", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M) = nextIntList()\n val array = Array(M) {\n val (P, Y) = nextIntList()\n intArrayOf(P, Y)\n }\n val counter = IntArray(N + 1) { 0 }\n val sorted = array.sortedBy { it[1] }\n sorted.forEach {\n counter[it[0]]++\n it[1] = counter[it[0]]\n }\n array.forEach {\n pw.printf(\"%06d%06d\\n\", it[0], it[1])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1590724628, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s982675116.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s982675116", "user_id": "u860789370"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M) = nextIntList()\n val array = Array(M) {\n val (P, Y) = nextIntList()\n intArrayOf(P, Y)\n }\n val counter = IntArray(N + 1) { 0 }\n val sorted = array.sortedBy { it[1] }\n sorted.forEach {\n counter[it[0]]++\n it[1] = counter[it[0]]\n }\n array.forEach {\n pw.printf(\"%06d%06d\\n\", it[0], it[1])\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 898, "cpu_time_ms": 1763, "memory_kb": 130780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s908584982", "group_id": "codeNet:p03221", "input_text": "import java.io.PrintWriter\nimport kotlin.comparisons.compareBy\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M) = nextIntList()\n val array = Array(M) {\n val (P, Y) = nextIntList()\n intArrayOf(P, Y)\n }\n val sorted = array.copyOf().sortedWith(compareBy({ it[0] }, { it[1] }))\n var curr = sorted[0][0]\n var count = 0\n for (a in sorted) {\n if (curr == a[0]) {\n a[1] = ++count\n } else {\n a[1] = 1\n count = 1\n curr = a[0]\n }\n }\n for (a in array) {\n pw.printf(\"%06d%06d\\n\", a[0], a[1])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1590724144, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s908584982.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908584982", "user_id": "u860789370"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.comparisons.compareBy\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M) = nextIntList()\n val array = Array(M) {\n val (P, Y) = nextIntList()\n intArrayOf(P, Y)\n }\n val sorted = array.copyOf().sortedWith(compareBy({ it[0] }, { it[1] }))\n var curr = sorted[0][0]\n var count = 0\n for (a in sorted) {\n if (curr == a[0]) {\n a[1] = ++count\n } else {\n a[1] = 1\n count = 1\n curr = a[0]\n }\n }\n for (a in array) {\n pw.printf(\"%06d%06d\\n\", a[0], a[1])\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1071, "cpu_time_ms": 1740, "memory_kb": 133236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s970691776", "group_id": "codeNet:p03221", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val M = sc.next().toInt()\n val PY = (0 until M).map { Triple(it, sc.next().toInt(), sc.next().toInt()) }\n .sortedBy { it.third }\n val seq = IntArray(N)\n val ans = LongArray(M)\n PY.forEach {\n val p = it.second - 1\n seq[p]++\n ans[it.first] = (p + 1) * 1000000L + seq[p]\n }\n ans.forEach {\n pw.printf(\"%012d\\n\", it)\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1587259206, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s970691776.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970691776", "user_id": "u297767059"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: Scanner, pw: java.io.PrintWriter) {\n val N = sc.next().toInt()\n val M = sc.next().toInt()\n val PY = (0 until M).map { Triple(it, sc.next().toInt(), sc.next().toInt()) }\n .sortedBy { it.third }\n val seq = IntArray(N)\n val ans = LongArray(M)\n PY.forEach {\n val p = it.second - 1\n seq[p]++\n ans[it.first] = (p + 1) * 1000000L + seq[p]\n }\n ans.forEach {\n pw.printf(\"%012d\\n\", it)\n }\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 699, "cpu_time_ms": 1477, "memory_kb": 130212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s314662417", "group_id": "codeNet:p03221", "input_text": "fun main(arr:Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val cityCount = (1..n).map { 0 }.toMutableList()\n val ans = StringBuilder()\n val city = (0 until m).map {idx -> readLine()!!.split(\" \").let { City(idx, it[0].toInt(), it[1].toLong()) } }\n city.sortedBy { it.year }.forEach {\n cityCount[it.ken - 1]++\n it.num = it.ken.toString().padStart(6, '0') + cityCount[it.ken - 1].toString().padStart(6, '0')\n }\n city.forEach { ans.appendln(it.num) }\n print(ans.toString())\n}\nclass City(val id:Int, val ken:Int, val year:Long) {\n var num:String = \"\"\n}", "language": "Kotlin", "metadata": {"date": 1580392873, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s314662417.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s314662417", "user_id": "u269969976"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "fun main(arr:Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val cityCount = (1..n).map { 0 }.toMutableList()\n val ans = StringBuilder()\n val city = (0 until m).map {idx -> readLine()!!.split(\" \").let { City(idx, it[0].toInt(), it[1].toLong()) } }\n city.sortedBy { it.year }.forEach {\n cityCount[it.ken - 1]++\n it.num = it.ken.toString().padStart(6, '0') + cityCount[it.ken - 1].toString().padStart(6, '0')\n }\n city.forEach { ans.appendln(it.num) }\n print(ans.toString())\n}\nclass City(val id:Int, val ken:Int, val year:Long) {\n var num:String = \"\"\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 616, "cpu_time_ms": 1029, "memory_kb": 87528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s160897021", "group_id": "codeNet:p03221", "input_text": "fun main(args: Array) {\n // 全体一括ソートは遅いはずだが,StringBuilder を使っている部分で実行速度が上がっている??\n\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 各県の初期ランクを定義\n var rank = IntArray(n + 1) { 1 }\n\n\n // 全ての市を year で一括並び替え\n val cities=(1..m).map {\n // map の中で複数の式を定義している\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n\n // map の lambda式でのローカルリターンを定義(@map が付いていないと main でのリターンになってしまう)\n // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec\n // return が明示的に書かれているとわかりやすいが, return を書かなくても最後の式の評価結果が戻り値となる\n return@map Triple(it, p, y)\n }.sortedBy { it.third }\n\n// val sb=StringBuilder()\n//\n// // 各市に県内で何番目かの情報を付与した後に,入力順にソート\n// cities.map {\n// // 同じ県内で何番目かの情報付与\n// Pair(it,rank[it.second]++)\n// }.sortedBy {\n// // データの入力順にソート\n// it.first.first\n// }.forEach {\n// // 出力文字列を StringBuilder に格納\n// sb.append(it.first.second.toString().padStart(6,'0'))\n// sb.append(it.second.toString().padStart(6,'0'))\n// sb.append(\"\\n\")\n// }\n//\n// // まとめて出力\n// println(sb)\n\n // 仮にStringBuilder を使わなかった場合\n\n // 各市に県内で何番目かの情報を付与した後に,入力順にソート\n val ans = cities.map {\n // 同じ県内で何番目かの情報付与\n Pair(it,rank[it.second]++)\n }.sortedBy {\n // データの入力順にソート\n it.first.first\n }.map {\n // 出力文字列を StringBuilder に格納\n it.first.second.toString().padStart(6,'0') + it.second.toString().padStart(6,'0')\n }\n\n println(ans.joinToString(\"\\n\"))\n}\n", "language": "Kotlin", "metadata": {"date": 1567357923, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s160897021.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160897021", "user_id": "u889750959"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "fun main(args: Array) {\n // 全体一括ソートは遅いはずだが,StringBuilder を使っている部分で実行速度が上がっている??\n\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 各県の初期ランクを定義\n var rank = IntArray(n + 1) { 1 }\n\n\n // 全ての市を year で一括並び替え\n val cities=(1..m).map {\n // map の中で複数の式を定義している\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n\n // map の lambda式でのローカルリターンを定義(@map が付いていないと main でのリターンになってしまう)\n // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec\n // return が明示的に書かれているとわかりやすいが, return を書かなくても最後の式の評価結果が戻り値となる\n return@map Triple(it, p, y)\n }.sortedBy { it.third }\n\n// val sb=StringBuilder()\n//\n// // 各市に県内で何番目かの情報を付与した後に,入力順にソート\n// cities.map {\n// // 同じ県内で何番目かの情報付与\n// Pair(it,rank[it.second]++)\n// }.sortedBy {\n// // データの入力順にソート\n// it.first.first\n// }.forEach {\n// // 出力文字列を StringBuilder に格納\n// sb.append(it.first.second.toString().padStart(6,'0'))\n// sb.append(it.second.toString().padStart(6,'0'))\n// sb.append(\"\\n\")\n// }\n//\n// // まとめて出力\n// println(sb)\n\n // 仮にStringBuilder を使わなかった場合\n\n // 各市に県内で何番目かの情報を付与した後に,入力順にソート\n val ans = cities.map {\n // 同じ県内で何番目かの情報付与\n Pair(it,rank[it.second]++)\n }.sortedBy {\n // データの入力順にソート\n it.first.first\n }.map {\n // 出力文字列を StringBuilder に格納\n it.first.second.toString().padStart(6,'0') + it.second.toString().padStart(6,'0')\n }\n\n println(ans.joinToString(\"\\n\"))\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2137, "cpu_time_ms": 1305, "memory_kb": 132692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s088637110", "group_id": "codeNet:p03221", "input_text": "\nfun main(args: Array) {\n // 全体一括ソートは遅いはずだが,StringBuilder を使っている部分で実行速度が上がっている??\n\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 各県の初期ランクを定義\n var rank = IntArray(n + 1) { 1 }\n\n\n // 全ての市を year で一括並び替え\n val cities=(1..m).map {\n // map の中で複数の式を定義している\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n\n // map の lambda式でのローカルリターンを定義(@map が付いていないと main でのリターンになってしまう)\n // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec\n // return が明示的に書かれているとわかりやすいが, return を書かなくても最後の式の評価結果が戻り値となる\n return@map Triple(it, p, y)\n }.sortedBy { it.third }\n\n val sb=StringBuilder()\n\n // 各市に県内で何番目かの情報を付与した後に,入力順にソート\n cities.map {\n // 同じ県内で何番目かの情報付与\n Pair(it,rank[it.second]++)\n }.sortedBy {\n // データの入力順にソート\n it.first.first\n }.forEach {\n // 出力文字列を StringBuilder に格納\n sb.append(it.first.second.toString().padStart(6,'0'))\n sb.append(it.second.toString().padStart(6,'0'))\n sb.append(\"\\n\")\n }\n\n // まとめて出力\n println(sb)\n}\n", "language": "Kotlin", "metadata": {"date": 1567357584, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s088637110.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s088637110", "user_id": "u889750959"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "\nfun main(args: Array) {\n // 全体一括ソートは遅いはずだが,StringBuilder を使っている部分で実行速度が上がっている??\n\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n\n // 各県の初期ランクを定義\n var rank = IntArray(n + 1) { 1 }\n\n\n // 全ての市を year で一括並び替え\n val cities=(1..m).map {\n // map の中で複数の式を定義している\n val (p, y) = readLine()!!.split(\" \").map { it.toInt() }\n\n // map の lambda式でのローカルリターンを定義(@map が付いていないと main でのリターンになってしまう)\n // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec\n // return が明示的に書かれているとわかりやすいが, return を書かなくても最後の式の評価結果が戻り値となる\n return@map Triple(it, p, y)\n }.sortedBy { it.third }\n\n val sb=StringBuilder()\n\n // 各市に県内で何番目かの情報を付与した後に,入力順にソート\n cities.map {\n // 同じ県内で何番目かの情報付与\n Pair(it,rank[it.second]++)\n }.sortedBy {\n // データの入力順にソート\n it.first.first\n }.forEach {\n // 出力文字列を StringBuilder に格納\n sb.append(it.first.second.toString().padStart(6,'0'))\n sb.append(it.second.toString().padStart(6,'0'))\n sb.append(\"\\n\")\n }\n\n // まとめて出力\n println(sb)\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1553, "cpu_time_ms": 1282, "memory_kb": 129028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s114956579", "group_id": "codeNet:p03221", "input_text": "import java.util.*\n\nfun main(args : Array) {\n println(inOutExec(Scanner(System.`in`)))\n// println(\"\" + inOutExec(null))\n}\n\nfun inOutExec(scanner: Scanner): String {\n// val (numOfPref, numOfCity) = readLine()!!.split(\" \").map { it.toInt() }\n val numOfPref = scanner.nextInt()\n val numOfCity = scanner.nextInt()\n\n val citiesIn = ArrayList>(numOfCity)\n repeat(numOfCity) {\n val (pref, year) = readLine()!!.split(\" \").map { it.toInt() }\n citiesIn.add(Pair(pref, year))\n// citiesIn.add(Pair(scanner.nextInt(), scanner.nextInt()))\n }\n\n val citiesMap = mutableMapOf>>()\n citiesIn.sortedBy { it.second }\n .forEach {\n if (it.first !in citiesMap) citiesMap[it.first] = ArrayList(numOfCity)\n citiesMap[it.first]!!.add(it)\n }\n\n val sb = StringBuilder()\n for (city in citiesIn) {\n sb.append(city.first.toString().padStart(6, '0'))\n .append((citiesMap[city.first]!!.indexOf(city) + 1).toString().padStart(6, '0'))\n .append(\"\\n\")\n }\n return sb.toString()\n}\n", "language": "Kotlin", "metadata": {"date": 1542869646, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s114956579.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s114956579", "user_id": "u940096433"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n println(inOutExec(Scanner(System.`in`)))\n// println(\"\" + inOutExec(null))\n}\n\nfun inOutExec(scanner: Scanner): String {\n// val (numOfPref, numOfCity) = readLine()!!.split(\" \").map { it.toInt() }\n val numOfPref = scanner.nextInt()\n val numOfCity = scanner.nextInt()\n\n val citiesIn = ArrayList>(numOfCity)\n repeat(numOfCity) {\n val (pref, year) = readLine()!!.split(\" \").map { it.toInt() }\n citiesIn.add(Pair(pref, year))\n// citiesIn.add(Pair(scanner.nextInt(), scanner.nextInt()))\n }\n\n val citiesMap = mutableMapOf>>()\n citiesIn.sortedBy { it.second }\n .forEach {\n if (it.first !in citiesMap) citiesMap[it.first] = ArrayList(numOfCity)\n citiesMap[it.first]!!.add(it)\n }\n\n val sb = StringBuilder()\n for (city in citiesIn) {\n sb.append(city.first.toString().padStart(6, '0'))\n .append((citiesMap[city.first]!!.indexOf(city) + 1).toString().padStart(6, '0'))\n .append(\"\\n\")\n }\n return sb.toString()\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1147, "cpu_time_ms": 638, "memory_kb": 62220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s462027304", "group_id": "codeNet:p03221", "input_text": "import java.util.*\n\nfun main(args : Array) {\n// val scanner = Scanner(System.`in`)\n println(inOutExec(null))\n}\n\nfun inOutExec(scanner: Scanner?): String {\n val (numOfPref, numOfCity) = readLine()!!.split(\" \").map { it.toInt() }\n\n val citiesIn = mutableListOf>()\n repeat(numOfCity) {\n val (pref, year) = readLine()!!.split(\" \").map { it.toInt() }\n citiesIn.add(Pair(pref, year))\n }\n\n val cityCodeMap = citiesIn\n .groupByTo(mutableMapOf()) { it.first }\n .flatMap { entry ->\n entry.value\n .sortedBy { info -> info.second }\n .mapIndexed { index, pair ->\n pair to \"%06d%06d\".format(pair.first, index + 1) } } // Pair, String>\n .toMap()\n\n return citiesIn.joinToString(separator = \"\\n\", postfix = \"\\n\") { cityCodeMap[it]!! }\n}\n", "language": "Kotlin", "metadata": {"date": 1542782207, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/Kotlin/s462027304.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s462027304", "user_id": "u940096433"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n// val scanner = Scanner(System.`in`)\n println(inOutExec(null))\n}\n\nfun inOutExec(scanner: Scanner?): String {\n val (numOfPref, numOfCity) = readLine()!!.split(\" \").map { it.toInt() }\n\n val citiesIn = mutableListOf>()\n repeat(numOfCity) {\n val (pref, year) = readLine()!!.split(\" \").map { it.toInt() }\n citiesIn.add(Pair(pref, year))\n }\n\n val cityCodeMap = citiesIn\n .groupByTo(mutableMapOf()) { it.first }\n .flatMap { entry ->\n entry.value\n .sortedBy { info -> info.second }\n .mapIndexed { index, pair ->\n pair to \"%06d%06d\".format(pair.first, index + 1) } } // Pair, String>\n .toMap()\n\n return citiesIn.joinToString(separator = \"\\n\", postfix = \"\\n\") { cityCodeMap[it]!! }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 917, "cpu_time_ms": 1787, "memory_kb": 148252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s787962539", "group_id": "codeNet:p03222", "input_text": "fun main(args: Array) {\n val (H, W, K) = listOfInt()\n val MOD = 1000000007\n val dp = Array(H + 1) { IntArray(W) }\n dp[0][0] = 1\n for (i in 0 until H) {\n for (j in 0 until W) {\n for (k in 0 until (1 shl (W - 1))) {\n var ok = true\n for (l in 0 until W - 2) {\n if ((k shr l) and 1 == 1 && (k shr (l + 1)) and 1 == 1) {\n ok = false\n }\n }\n if (ok) {\n if (j >= 1 && (k shr (j - 1)) and 1 == 1) {\n dp[i + 1][j - 1] += dp[i][j]\n dp[i + 1][j - 1] %= MOD\n } else if (j <= W - 2 && (k shr j) and 1 == 1) {\n dp[i + 1][j + 1] += dp[i][j]\n dp[i + 1][j + 1] %= MOD\n } else {\n dp[i + 1][j] += dp[i][j]\n dp[i + 1][j] %= MOD\n }\n }\n }\n }\n }\n println(dp[H][K - 1])\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1583860654, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03222.html", "problem_id": "p03222", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03222/input.txt", "sample_output_relpath": "derived/input_output/data/p03222/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03222/Kotlin/s787962539.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s787962539", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W, K) = listOfInt()\n val MOD = 1000000007\n val dp = Array(H + 1) { IntArray(W) }\n dp[0][0] = 1\n for (i in 0 until H) {\n for (j in 0 until W) {\n for (k in 0 until (1 shl (W - 1))) {\n var ok = true\n for (l in 0 until W - 2) {\n if ((k shr l) and 1 == 1 && (k shr (l + 1)) and 1 == 1) {\n ok = false\n }\n }\n if (ok) {\n if (j >= 1 && (k shr (j - 1)) and 1 == 1) {\n dp[i + 1][j - 1] += dp[i][j]\n dp[i + 1][j - 1] %= MOD\n } else if (j <= W - 2 && (k shr j) and 1 == 1) {\n dp[i + 1][j + 1] += dp[i][j]\n dp[i + 1][j + 1] %= MOD\n } else {\n dp[i + 1][j] += dp[i][j]\n dp[i + 1][j] %= MOD\n }\n }\n }\n }\n }\n println(dp[H][K - 1])\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAmidakuji is a traditional method of lottery in Japan.\n\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.\n\nA valid amidakuji is an amidakuji that satisfies the following conditions:\n\nNo two horizontal lines share an endpoint.\n\nThe two endpoints of each horizontal lines must be at the same height.\n\nA horizontal line must connect adjacent vertical lines.\n\nFind the number of the valid amidakuji that satisfy the following condition, modulo 1\\ 000\\ 000\\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.\n\nFor example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.\n\nConstraints\n\nH is an integer between 1 and 100 (inclusive).\n\nW is an integer between 1 and 8 (inclusive).\n\nK is an integer between 1 and W (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\n\nOutput\n\nPrint the number of the amidakuji that satisfy the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 2\n\n1 3 1\n\nSample Output 2\n\n2\n\nOnly the following two amidakuji satisfy the condition:\n\nSample Input 3\n\n2 3 3\n\nSample Output 3\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 4\n\n2 3 1\n\nSample Output 4\n\n5\n\nOnly the following five amidakuji satisfy the condition:\n\nSample Input 5\n\n7 1 1\n\nSample Output 5\n\n1\n\nAs there is only one vertical line, we cannot draw any horizontal lines. Thus, there is only one amidakuji that satisfies the condition: the amidakuji with no horizontal lines.\n\nSample Input 6\n\n15 8 5\n\nSample Output 6\n\n437760187\n\nBe sure to print the answer modulo 1\\ 000\\ 000\\ 007.", "sample_input": "1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03222", "source_text": "Score: 400 points\n\nProblem Statement\n\nAmidakuji is a traditional method of lottery in Japan.\n\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.\n\nA valid amidakuji is an amidakuji that satisfies the following conditions:\n\nNo two horizontal lines share an endpoint.\n\nThe two endpoints of each horizontal lines must be at the same height.\n\nA horizontal line must connect adjacent vertical lines.\n\nFind the number of the valid amidakuji that satisfy the following condition, modulo 1\\ 000\\ 000\\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.\n\nFor example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.\n\nConstraints\n\nH is an integer between 1 and 100 (inclusive).\n\nW is an integer between 1 and 8 (inclusive).\n\nK is an integer between 1 and W (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\n\nOutput\n\nPrint the number of the amidakuji that satisfy the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 2\n\n1 3 1\n\nSample Output 2\n\n2\n\nOnly the following two amidakuji satisfy the condition:\n\nSample Input 3\n\n2 3 3\n\nSample Output 3\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 4\n\n2 3 1\n\nSample Output 4\n\n5\n\nOnly the following five amidakuji satisfy the condition:\n\nSample Input 5\n\n7 1 1\n\nSample Output 5\n\n1\n\nAs there is only one vertical line, we cannot draw any horizontal lines. Thus, there is only one amidakuji that satisfies the condition: the amidakuji with no horizontal lines.\n\nSample Input 6\n\n15 8 5\n\nSample Output 6\n\n437760187\n\nBe sure to print the answer modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1189, "cpu_time_ms": 269, "memory_kb": 38880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s483438412", "group_id": "codeNet:p03227", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n\n when (s.length) {\n 2 -> println(s)\n 3 -> println(s.reversed())\n }\n}", "language": "Kotlin", "metadata": {"date": 1540688685, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03227.html", "problem_id": "p03227", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03227/input.txt", "sample_output_relpath": "derived/input_output/data/p03227/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03227/Kotlin/s483438412.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s483438412", "user_id": "u471214054"}, "prompt_components": {"gold_output": "cba\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n\n when (s.length) {\n 2 -> println(s)\n 3 -> println(s.reversed())\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\nThe length of S is 2 or 3.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1\n\nabc\n\nSample Output 1\n\ncba\n\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2\n\nac\n\nSample Output 2\n\nac\n\nAs the length of S is 2, we print it as is.", "sample_input": "abc\n"}, "reference_outputs": ["cba\n"], "source_document_id": "p03227", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\nThe length of S is 2 or 3.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1\n\nabc\n\nSample Output 1\n\ncba\n\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2\n\nac\n\nSample Output 2\n\nac\n\nAs the length of S is 2, we print it as is.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 146, "cpu_time_ms": 237, "memory_kb": 33616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s071636727", "group_id": "codeNet:p03228", "input_text": "fun main(arr:Array) {\n var (a,b,k) = readLine()!!.split(\" \").map { it.toInt() }\n for(i in (0 until k)) {\n if(i % 2 == 0) {\n if(a%2!=0) {\n a--\n }\n b += a/2\n a /= 2\n } else {\n if(b%2!=0) {\n b--\n }\n a += b/2\n b /= 2\n }\n }\n println(\"%d %d\".format(a,b))\n}\n", "language": "Kotlin", "metadata": {"date": 1586026455, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03228.html", "problem_id": "p03228", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03228/input.txt", "sample_output_relpath": "derived/input_output/data/p03228/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03228/Kotlin/s071636727.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071636727", "user_id": "u269969976"}, "prompt_components": {"gold_output": "5 3\n", "input_to_evaluate": "fun main(arr:Array) {\n var (a,b,k) = readLine()!!.split(\" \").map { it.toInt() }\n for(i in (0 until k)) {\n if(i % 2 == 0) {\n if(a%2!=0) {\n a--\n }\n b += a/2\n a /= 2\n } else {\n if(b%2!=0) {\n b--\n }\n a += b/2\n b /= 2\n }\n }\n println(\"%d %d\".format(a,b))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "sample_input": "5 4 2\n"}, "reference_outputs": ["5 3\n"], "source_document_id": "p03228", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 410, "cpu_time_ms": 236, "memory_kb": 37932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s163783929", "group_id": "codeNet:p03228", "input_text": "fun main(args: Array) {\n tenka12018beginner_b()\n}\n\nfun tenka12018beginner_b() {\n var (a, b, k) = readLine()!!.split(' ').map { it.toLong() }\n\n var turnOfA = true\n while (k-- > 0) {\n if (turnOfA) {\n b += a / 2\n a /= 2\n } else {\n a += b / 2\n b /= 2\n }\n turnOfA = !turnOfA\n }\n\n val answer = \"$a $b\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1576036721, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03228.html", "problem_id": "p03228", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03228/input.txt", "sample_output_relpath": "derived/input_output/data/p03228/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03228/Kotlin/s163783929.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163783929", "user_id": "u139478771"}, "prompt_components": {"gold_output": "5 3\n", "input_to_evaluate": "fun main(args: Array) {\n tenka12018beginner_b()\n}\n\nfun tenka12018beginner_b() {\n var (a, b, k) = readLine()!!.split(' ').map { it.toLong() }\n\n var turnOfA = true\n while (k-- > 0) {\n if (turnOfA) {\n b += a / 2\n a /= 2\n } else {\n a += b / 2\n b /= 2\n }\n turnOfA = !turnOfA\n }\n\n val answer = \"$a $b\"\n\n println(answer)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "sample_input": "5 4 2\n"}, "reference_outputs": ["5 3\n"], "source_document_id": "p03228", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 417, "cpu_time_ms": 239, "memory_kb": 37948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s330403392", "group_id": "codeNet:p03231", "input_text": "fun main(args : Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!\n val t = readLine()!!\n\n val lcm = lcm(n.toLong(), m.toLong())\n val stepN = (lcm/n).toInt()\n val stepM = (lcm/m).toInt()\n\n var nIdx = 0L\n var mIdx = 0L\n\n var nCnt = 0\n var mCnt = 0\n\n for (i in 0L until lcm) {\n if (i == nIdx && i == mIdx) {\n if (s[nCnt] != t[mCnt]) {\n println(\"-1\")\n return\n }\n\n nCnt++\n mCnt++\n\n nIdx = if(nCnt < n) nIdx + stepN else -1\n mIdx = if(mCnt < m) mIdx + stepM else -1\n } else if (i == nIdx) {\n nCnt++\n nIdx = if(nCnt < n) nIdx + stepN else -1\n } else if (i == mIdx) {\n mCnt++\n mIdx = if(mCnt < m) mIdx + stepM else -1\n }\n }\n\n println(lcm)\n}\n\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\nfun lcm(a : Long, b : Long) : Long {\n return (a * b) / gcd(a, b)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1589105266, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03231.html", "problem_id": "p03231", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03231/input.txt", "sample_output_relpath": "derived/input_output/data/p03231/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03231/Kotlin/s330403392.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s330403392", "user_id": "u262403099"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args : Array) {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val s = readLine()!!\n val t = readLine()!!\n\n val lcm = lcm(n.toLong(), m.toLong())\n val stepN = (lcm/n).toInt()\n val stepM = (lcm/m).toInt()\n\n var nIdx = 0L\n var mIdx = 0L\n\n var nCnt = 0\n var mCnt = 0\n\n for (i in 0L until lcm) {\n if (i == nIdx && i == mIdx) {\n if (s[nCnt] != t[mCnt]) {\n println(\"-1\")\n return\n }\n\n nCnt++\n mCnt++\n\n nIdx = if(nCnt < n) nIdx + stepN else -1\n mIdx = if(mCnt < m) mIdx + stepM else -1\n } else if (i == nIdx) {\n nCnt++\n nIdx = if(nCnt < n) nIdx + stepN else -1\n } else if (i == mIdx) {\n mCnt++\n mIdx = if(mCnt < m) mIdx + stepM else -1\n }\n }\n\n println(lcm)\n}\n\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\nfun lcm(a : Long, b : Long) : Long {\n return (a * b) / gcd(a, b)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N and another string T of length M.\nThese strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\nLet L be the length of X. L is divisible by both N and M.\n\nConcatenating the 1-st, (\\frac{L}{N}+1)-th, (2 \\times \\frac{L}{N}+1)-th, ..., ((N-1)\\times\\frac{L}{N}+1)-th characters of X, without changing the order, results in S.\n\nConcatenating the 1-st, (\\frac{L}{M}+1)-th, (2 \\times \\frac{L}{M}+1)-th, ..., ((M-1)\\times\\frac{L}{M}+1)-th characters of X, without changing the order, results in T.\n\nDetermine if there exists a good string. If it exists, find the length of the shortest such string.\n\nConstraints\n\n1 \\leq N,M \\leq 10^5\n\nS and T consist of lowercase English letters.\n\n|S|=N\n\n|T|=M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\nT\n\nOutput\n\nIf a good string does not exist, print -1; if it exists, print the length of the shortest such string.\n\nSample Input 1\n\n3 2\nacp\nae\n\nSample Output 1\n\n6\n\nFor example, the string accept is a good string.\nThere is no good string shorter than this, so the answer is 6.\n\nSample Input 2\n\n6 3\nabcdef\nabc\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n15 9\ndnsusrayukuaiia\ndujrunuma\n\nSample Output 3\n\n45", "sample_input": "3 2\nacp\nae\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03231", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N and another string T of length M.\nThese strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\nLet L be the length of X. L is divisible by both N and M.\n\nConcatenating the 1-st, (\\frac{L}{N}+1)-th, (2 \\times \\frac{L}{N}+1)-th, ..., ((N-1)\\times\\frac{L}{N}+1)-th characters of X, without changing the order, results in S.\n\nConcatenating the 1-st, (\\frac{L}{M}+1)-th, (2 \\times \\frac{L}{M}+1)-th, ..., ((M-1)\\times\\frac{L}{M}+1)-th characters of X, without changing the order, results in T.\n\nDetermine if there exists a good string. If it exists, find the length of the shortest such string.\n\nConstraints\n\n1 \\leq N,M \\leq 10^5\n\nS and T consist of lowercase English letters.\n\n|S|=N\n\n|T|=M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\nT\n\nOutput\n\nIf a good string does not exist, print -1; if it exists, print the length of the shortest such string.\n\nSample Input 1\n\n3 2\nacp\nae\n\nSample Output 1\n\n6\n\nFor example, the string accept is a good string.\nThere is no good string shorter than this, so the answer is 6.\n\nSample Input 2\n\n6 3\nabcdef\nabc\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n15 9\ndnsusrayukuaiia\ndujrunuma\n\nSample Output 3\n\n45", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1047, "cpu_time_ms": 2111, "memory_kb": 41352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s335596844", "group_id": "codeNet:p03238", "input_text": "import java.util.*\n\nobject MainKt {\n @JvmStatic\n fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n\n when(n){\n 1 -> println(\"Hello World\")\n 2 -> {\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n println(a+b)\n }\n }\n\n }\n}", "language": "Kotlin", "metadata": {"date": 1555716629, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Kotlin/s335596844.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s335596844", "user_id": "u914590612"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "import java.util.*\n\nobject MainKt {\n @JvmStatic\n fun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n\n when(n){\n 1 -> println(\"Hello World\")\n 2 -> {\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n println(a+b)\n }\n }\n\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 386, "cpu_time_ms": 188, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s744493308", "group_id": "codeNet:p03239", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Long, T: Long, c: LongArray, t: LongArray){\n val ans = (0 until N.toInt()).map{ c[it] to t[it] }.filter{ it.second <= T }.minBy{ it.first }?.first\n println(ans?: \"TLE\")\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toLong()\n val T = sc.next().toLong()\n val c = LongArray(N.toInt())\n val t = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n c[i] = sc.next().toLong()\n t[i] = sc.next().toLong()\n }\n solve(N, T, c, t)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1563363801, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Kotlin/s744493308.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744493308", "user_id": "u329232967"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Long, T: Long, c: LongArray, t: LongArray){\n val ans = (0 until N.toInt()).map{ c[it] to t[it] }.filter{ it.second <= T }.minBy{ it.first }?.first\n println(ans?: \"TLE\")\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toLong()\n val T = sc.next().toLong()\n val c = LongArray(N.toInt())\n val t = LongArray(N.toInt())\n for (i in 0 until N.toInt()) {\n c[i] = sc.next().toLong()\n t[i] = sc.next().toLong()\n }\n solve(N, T, c, t)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1037, "cpu_time_ms": 206, "memory_kb": 31492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s091068864", "group_id": "codeNet:p03239", "input_text": "import java.util.*\n\nfun main(args:Array){\n val scan = Scanner(System.`in`)\n val n = scan.nextInt()\n val totalTime = scan.nextInt()\n var cost = 0\n var time = 0\n var min = 1000\n var count = 0\n for (i in 1..n) {\n cost = scan.nextInt()\n time = scan.nextInt()\n if(time <= totalTime && min > cost) min = cost else count++\n }\n println(if(count != n) cost else \"TLE\")\n}", "language": "Kotlin", "metadata": {"date": 1539799345, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Kotlin/s091068864.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s091068864", "user_id": "u618112953"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val scan = Scanner(System.`in`)\n val n = scan.nextInt()\n val totalTime = scan.nextInt()\n var cost = 0\n var time = 0\n var min = 1000\n var count = 0\n for (i in 1..n) {\n cost = scan.nextInt()\n time = scan.nextInt()\n if(time <= totalTime && min > cost) min = cost else count++\n }\n println(if(count != n) cost else \"TLE\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 199, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s426884786", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array) {\n val (n,m)= readLine()!!.split(\" \").map{it.toLong()}\n (1L..Math.sqrt(m.toDouble()).toLong())\n .filter { m%it==0L }\n .map { listOf(it, m/it) }.flatten()\n .sorted()\n .last{ it*n<=m }\n .let { println(it) }\n\n}", "language": "Kotlin", "metadata": {"date": 1541478389, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Kotlin/s426884786.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s426884786", "user_id": "u914096045"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,m)= readLine()!!.split(\" \").map{it.toLong()}\n (1L..Math.sqrt(m.toDouble()).toLong())\n .filter { m%it==0L }\n .map { listOf(it, m/it) }.flatten()\n .sorted()\n .last{ it*n<=m }\n .let { println(it) }\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 266, "memory_kb": 38580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s606708394", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n\n var max = Math.min((m/n), Math.sqrt(m.toDouble()).toInt())\n for (d in max downTo 1) {\n if (m % d == 0) {\n println(d)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1539703484, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Kotlin/s606708394.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s606708394", "user_id": "u367259152"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, m) = readLine()!!.split(\" \").map(String::toInt)\n\n var max = Math.min((m/n), Math.sqrt(m.toDouble()).toInt())\n for (d in max downTo 1) {\n if (m % d == 0) {\n println(d)\n return\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 271, "cpu_time_ms": 244, "memory_kb": 37900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s792056181", "group_id": "codeNet:p03241", "input_text": "import java.util.*\n\nfun main(args: Array) {\n\tval scanner = Scanner(System.`in`)\n\tval n = scanner.nextLong()\n\tval m = scanner.nextLong()\n\tvar a=m\n\tvar b=n\n\tif(m%n==0L){\n\t\tprintln(n)\n\t\treturn\n\t}\n\twhile(a%b!=0L){\n\t\tval tmp=b\n\t\tb=a%b\n\t\ta=tmp\n\t}\n\tprintln(a)\n}", "language": "Kotlin", "metadata": {"date": 1538907232, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Kotlin/s792056181.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s792056181", "user_id": "u957575129"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n\tval scanner = Scanner(System.`in`)\n\tval n = scanner.nextLong()\n\tval m = scanner.nextLong()\n\tvar a=m\n\tvar b=n\n\tif(m%n==0L){\n\t\tprintln(n)\n\t\treturn\n\t}\n\twhile(a%b!=0L){\n\t\tval tmp=b\n\t\tb=a%b\n\t\ta=tmp\n\t}\n\tprintln(a)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 174, "memory_kb": 31520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s677443796", "group_id": "codeNet:p03241", "input_text": "fun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n if (N > M / 2) {\n println(1)\n return\n }\n for (i in N..(M / 2)) {\n if (M % i == 0) {\n println(M / i)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1538878318, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Kotlin/s677443796.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s677443796", "user_id": "u771276989"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toInt() }\n if (N > M / 2) {\n println(1)\n return\n }\n for (i in N..(M / 2)) {\n if (M % i == 0) {\n println(M / i)\n return\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 270, "cpu_time_ms": 1790, "memory_kb": 37956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s410618169", "group_id": "codeNet:p03243", "input_text": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n var ans = 0\n for (i in n..999) {\n val c = i.toString()\n if (c[0] == c[1] && c[1] == c[2]){\n ans = i\n break\n }\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1565142768, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03243.html", "problem_id": "p03243", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03243/input.txt", "sample_output_relpath": "derived/input_output/data/p03243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03243/Kotlin/s410618169.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410618169", "user_id": "u108272327"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "fun main(args: Array) {\n\n val n = readLine()!!.toInt()\n\n var ans = 0\n for (i in n..999) {\n val c = i.toString()\n if (c[0] == c[1] && c[1] == c[2]){\n ans = i\n break\n }\n }\n\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "sample_input": "111\n"}, "reference_outputs": ["111\n"], "source_document_id": "p03243", "source_text": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 206, "memory_kb": 31452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s068446038", "group_id": "codeNet:p03244", "input_text": "fun c111(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val firstList = numList.filterIndexed { index, num -> index % 2 == 0 }\n val secondList = numList.filterIndexed { index, num -> index % 2 == 1 }\n\n var firstMap = mutableMapOf()\n var firstMostCommonCount = 0\n var firstSecondMostCommonCount = 0\n var firstMostCommonNum = 0\n firstList.forEach {\n if (!firstMap.containsKey(it)) {\n firstMap.put(it, 0)\n }\n firstMap.put(it, firstMap[it]!! + 1)\n if (firstMostCommonCount < firstMap.get(it)!!) {\n firstSecondMostCommonCount = firstMostCommonCount\n firstMostCommonCount = firstMap.get(it)!! + 1\n firstMostCommonNum = it\n }\n }\n\n var secondMap = mutableMapOf()\n var secondMostCommonCount = 0\n var secondSecondMostCommonCount = 0\n var secondMostCommonNum = 0\n secondList.forEach {\n if (!secondMap.containsKey(it)) {\n secondMap.put(it, 0)\n }\n secondMap.put(it, secondMap[it]!! + 1)\n if (secondMostCommonCount < secondMap.get(it)!!) {\n secondSecondMostCommonCount = secondMostCommonCount\n secondMostCommonCount = secondMap.get(it)!! + 1\n secondMostCommonNum = it\n }\n }\n\n if (firstMostCommonNum != secondMostCommonNum) {\n println((firstList.size - firstMostCommonCount) + (secondList.size - secondMostCommonCount))\n } else {\n println(Math.min(\n (firstList.size - firstSecondMostCommonCount) + (secondList.size - secondMostCommonCount),\n (firstList.size - firstMostCommonCount) + (secondList.size - secondSecondMostCommonCount)))\n\n }\n}\n\n\nfun main(args: Array) {\n c111(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1541558047, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/Kotlin/s068446038.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s068446038", "user_id": "u227166381"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun c111(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val firstList = numList.filterIndexed { index, num -> index % 2 == 0 }\n val secondList = numList.filterIndexed { index, num -> index % 2 == 1 }\n\n var firstMap = mutableMapOf()\n var firstMostCommonCount = 0\n var firstSecondMostCommonCount = 0\n var firstMostCommonNum = 0\n firstList.forEach {\n if (!firstMap.containsKey(it)) {\n firstMap.put(it, 0)\n }\n firstMap.put(it, firstMap[it]!! + 1)\n if (firstMostCommonCount < firstMap.get(it)!!) {\n firstSecondMostCommonCount = firstMostCommonCount\n firstMostCommonCount = firstMap.get(it)!! + 1\n firstMostCommonNum = it\n }\n }\n\n var secondMap = mutableMapOf()\n var secondMostCommonCount = 0\n var secondSecondMostCommonCount = 0\n var secondMostCommonNum = 0\n secondList.forEach {\n if (!secondMap.containsKey(it)) {\n secondMap.put(it, 0)\n }\n secondMap.put(it, secondMap[it]!! + 1)\n if (secondMostCommonCount < secondMap.get(it)!!) {\n secondSecondMostCommonCount = secondMostCommonCount\n secondMostCommonCount = secondMap.get(it)!! + 1\n secondMostCommonNum = it\n }\n }\n\n if (firstMostCommonNum != secondMostCommonNum) {\n println((firstList.size - firstMostCommonCount) + (secondList.size - secondMostCommonCount))\n } else {\n println(Math.min(\n (firstList.size - firstSecondMostCommonCount) + (secondList.size - secondMostCommonCount),\n (firstList.size - firstMostCommonCount) + (secondList.size - secondSecondMostCommonCount)))\n\n }\n}\n\n\nfun main(args: Array) {\n c111(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2077, "cpu_time_ms": 673, "memory_kb": 58208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s294059415", "group_id": "codeNet:p03248", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val n = s.length\n val f = (0 until n / 2).any { s[it] != s[n - it - 2] }\n if (s[0] != '1' || s[n - 1] != '0' || f) {\n println(-1)\n return\n }\n val list = Array(n + 1) { it }.filter { it > 0 && s[it - 1] == '1' }.sorted()\n var p = 1\n var c = 1\n for (m in list) {\n while (c < m + 1) {\n c++\n println(\"$p $c\")\n }\n p = c\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1570838073, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03248.html", "problem_id": "p03248", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03248/input.txt", "sample_output_relpath": "derived/input_output/data/p03248/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03248/Kotlin/s294059415.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s294059415", "user_id": "u858748695"}, "prompt_components": {"gold_output": "-1\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val n = s.length\n val f = (0 until n / 2).any { s[it] != s[n - it - 2] }\n if (s[0] != '1' || s[n - 1] != '0' || f) {\n println(-1)\n return\n }\n val list = Array(n + 1) { it }.filter { it > 0 && s[it - 1] == '1' }.sorted()\n var p = 1\n var c = 1\n for (m in list) {\n while (c < m + 1) {\n c++\n println(\"$p $c\")\n }\n p = c\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n\nThe vertices are numbered 1,2,..., n.\n\nThe edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n\nIf the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.\n\nIf the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.\n\nIf such a tree exists, construct one such tree.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\ns is a string of length n consisting of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf a tree with n vertices that satisfies the conditions does not exist, print -1.\n\nIf a tree with n vertices that satisfies the conditions exist, print n-1 lines.\nThe i-th line should contain u_i and v_i with a space in between.\nIf there are multiple trees that satisfy the conditions, any such tree will be accepted.\n\nSample Input 1\n\n1111\n\nSample Output 1\n\n-1\n\nIt is impossible to have a connected component of size n after removing one edge from a tree with n vertices.\n\nSample Input 2\n\n1110\n\nSample Output 2\n\n1 2\n2 3\n3 4\n\nIf Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.\n\nSample Input 3\n\n1010\n\nSample Output 3\n\n1 2\n1 3\n1 4\n\nRemoving any edge will result in a connected component of size 1 and another of size 3.", "sample_input": "1111\n"}, "reference_outputs": ["-1\n"], "source_document_id": "p03248", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n\nThe vertices are numbered 1,2,..., n.\n\nThe edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n\nIf the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.\n\nIf the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.\n\nIf such a tree exists, construct one such tree.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\ns is a string of length n consisting of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf a tree with n vertices that satisfies the conditions does not exist, print -1.\n\nIf a tree with n vertices that satisfies the conditions exist, print n-1 lines.\nThe i-th line should contain u_i and v_i with a space in between.\nIf there are multiple trees that satisfy the conditions, any such tree will be accepted.\n\nSample Input 1\n\n1111\n\nSample Output 1\n\n-1\n\nIt is impossible to have a connected component of size n after removing one edge from a tree with n vertices.\n\nSample Input 2\n\n1110\n\nSample Output 2\n\n1 2\n2 3\n3 4\n\nIf Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.\n\nSample Input 3\n\n1010\n\nSample Output 3\n\n1 2\n1 3\n1 4\n\nRemoving any edge will result in a connected component of size 1 and another of size 3.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 984, "memory_kb": 46544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s844153439", "group_id": "codeNet:p03252", "input_text": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.HashMap\n\nfun main(args: Array){\n\n// var (H, W) = readLine()!!.split(\" \").map{it.toInt()}\n var S = readLine()!!.toCharArray()\n var T = readLine()!!.toCharArray()\n var ans = \"Yes\"\n var transMapS = HashMap()\n var transMapT = HashMap()\n\n for(i in S.indices){\n if(transMapS.containsKey(S[i])){\n if(transMapS.get(S[i]) != T[i]){\n ans = \"No\"\n break\n }\n } else {\n transMapS.set(S[i],T[i])\n }\n\n }\n\n for(i in T.indices){\n if(transMapT.containsKey(T[i])){\n if(transMapT.get(T[i]) != S[i]){\n ans = \"No\"\n break\n }\n } else {\n transMapT.set(T[i],S[i])\n }\n\n }\n println(ans)\n\n\n\n\n}", "language": "Kotlin", "metadata": {"date": 1600906630, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/Kotlin/s844153439.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s844153439", "user_id": "u579455624"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\nimport kotlin.collections.ArrayDeque\nimport kotlin.collections.HashMap\n\nfun main(args: Array){\n\n// var (H, W) = readLine()!!.split(\" \").map{it.toInt()}\n var S = readLine()!!.toCharArray()\n var T = readLine()!!.toCharArray()\n var ans = \"Yes\"\n var transMapS = HashMap()\n var transMapT = HashMap()\n\n for(i in S.indices){\n if(transMapS.containsKey(S[i])){\n if(transMapS.get(S[i]) != T[i]){\n ans = \"No\"\n break\n }\n } else {\n transMapS.set(S[i],T[i])\n }\n\n }\n\n for(i in T.indices){\n if(transMapT.containsKey(T[i])){\n if(transMapT.get(T[i]) != S[i]){\n ans = \"No\"\n break\n }\n } else {\n transMapT.set(T[i],S[i])\n }\n\n }\n println(ans)\n\n\n\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 876, "cpu_time_ms": 285, "memory_kb": 41832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s868178580", "group_id": "codeNet:p03253", "input_text": "fun main(args: Array) {\n val MOD = 1000000007L\n fun modpow(a: Long, p: Int): Long {\n if (p == 0) return 1\n return if (p % 2 == 0) {\n val halfP = p / 2\n val half = modpow(a, halfP)\n half * half % MOD\n } else {\n a * modpow(a, p - 1) % MOD\n }\n }\n\n fun calcComb(a: Int, b: Int): Long {\n if (b > a - b) return calcComb(a, a - b)\n var ansMul = 1L\n var ansDiv = 1L\n for (n in 0 until b) {\n ansMul *= (a - n).toLong()\n ansDiv *= (n + 1).toLong()\n ansMul %= MOD\n ansDiv %= MOD\n }\n return ansMul * modpow(ansDiv, MOD.toInt() - 2) % MOD\n }\n \n val (N, M) =listOfInt()\n var MNokori = M\n var ans = 1L\n var n = 2\n while (n * n <= MNokori) {\n if (MNokori % n == 0) {\n var cnt = 0\n while (MNokori % n == 0) {\n cnt++\n MNokori /= n\n }\n ans *= calcComb(N + cnt - 1, N - 1)\n ans %= MOD\n }\n n += 1\n }\n if (MNokori != 1) {\n ans *= calcComb(N + 1 - 1, N - 1)\n ans %= MOD\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n\n", "language": "Kotlin", "metadata": {"date": 1583948259, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Kotlin/s868178580.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s868178580", "user_id": "u043150661"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val MOD = 1000000007L\n fun modpow(a: Long, p: Int): Long {\n if (p == 0) return 1\n return if (p % 2 == 0) {\n val halfP = p / 2\n val half = modpow(a, halfP)\n half * half % MOD\n } else {\n a * modpow(a, p - 1) % MOD\n }\n }\n\n fun calcComb(a: Int, b: Int): Long {\n if (b > a - b) return calcComb(a, a - b)\n var ansMul = 1L\n var ansDiv = 1L\n for (n in 0 until b) {\n ansMul *= (a - n).toLong()\n ansDiv *= (n + 1).toLong()\n ansMul %= MOD\n ansDiv %= MOD\n }\n return ansMul * modpow(ansDiv, MOD.toInt() - 2) % MOD\n }\n \n val (N, M) =listOfInt()\n var MNokori = M\n var ans = 1L\n var n = 2\n while (n * n <= MNokori) {\n if (MNokori % n == 0) {\n var cnt = 0\n while (MNokori % n == 0) {\n cnt++\n MNokori /= n\n }\n ans *= calcComb(N + cnt - 1, N - 1)\n ans %= MOD\n }\n n += 1\n }\n if (MNokori != 1) {\n ans *= calcComb(N + 1 - 1, N - 1)\n ans %= MOD\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1437, "cpu_time_ms": 238, "memory_kb": 38032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s443329904", "group_id": "codeNet:p03253", "input_text": "fun main(args: Array) {\n val mod = 1000000007\n var (N, M) = readLongList()\n\n var q = 2\n val list = mutableListOf()\n val comb = Comb(200000, mod)\n var m = M\n\n for (q in 2..Math.sqrt(M.toDouble()).toInt()) {\n var count = 0\n while (m % q == 0) {\n m /= q\n count++\n }\n\n if (count != 0)\n list.add(count)\n }\n\n //Mが素数の場合\n if (m != 1)\n list.add(1)\n\n //|||||->||o|o 5C2 (n 4)\n var ans = 1L\n for (i in list) {\n ans = (ans * comb[N+i-1, i]) %mod\n }\n\n println(ans)\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toInt)\n\nclass Comb(val max:Int, val mod:Int) {\n val fac = LongArray(max).apply { this[0] = 1L; this[1] = 1L }\n val finv = LongArray(max).apply { this[0] = 1L; this[1] = 1L }\n val inv = LongArray(max).apply { this[1] = 1L }\n\n init {\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % mod\n inv[i] = mod - inv[mod % i] * (mod / i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n }\n }\n\n operator fun get(n:Int, k:Int):Long{\n if (n < k) return 0\n if (n < 0 || k < 0) return 0\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod\n }\n}", "language": "Kotlin", "metadata": {"date": 1566505156, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Kotlin/s443329904.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s443329904", "user_id": "u043557308"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val mod = 1000000007\n var (N, M) = readLongList()\n\n var q = 2\n val list = mutableListOf()\n val comb = Comb(200000, mod)\n var m = M\n\n for (q in 2..Math.sqrt(M.toDouble()).toInt()) {\n var count = 0\n while (m % q == 0) {\n m /= q\n count++\n }\n\n if (count != 0)\n list.add(count)\n }\n\n //Mが素数の場合\n if (m != 1)\n list.add(1)\n\n //|||||->||o|o 5C2 (n 4)\n var ans = 1L\n for (i in list) {\n ans = (ans * comb[N+i-1, i]) %mod\n }\n\n println(ans)\n}\n\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toInt)\n\nclass Comb(val max:Int, val mod:Int) {\n val fac = LongArray(max).apply { this[0] = 1L; this[1] = 1L }\n val finv = LongArray(max).apply { this[0] = 1L; this[1] = 1L }\n val inv = LongArray(max).apply { this[1] = 1L }\n\n init {\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % mod\n inv[i] = mod - inv[mod % i] * (mod / i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n }\n }\n\n operator fun get(n:Int, k:Int):Long{\n if (n < k) return 0\n if (n < 0 || k < 0) return 0\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1446, "cpu_time_ms": 270, "memory_kb": 40724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s699447956", "group_id": "codeNet:p03253", "input_text": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toLong() }\n val fact = primeFactor(M.toInt())\n val MOD = 1000000000+7L\n if (fact.entries.size == 0) {\n println(0)\n return\n }\n var ans = 1L\n fact.entries.forEach {\n // N 個\n ans = ans * nCk(it.value + (N-1), N-1, MOD) % MOD\n }\n println(ans)\n}\n\n\n// O(N^0.5)\n// O(√n)\nfun primeFactor(n: Int) : Map {\n val map = mutableMapOf()\n var num = n;\n for (i in 2..(Math.sqrt(n.toDouble())).toInt()) {\n // iで割れるところまで割り続ける\n while (num % i == 0) {\n if (map[i] == null) {\n map[i] = 1\n } else {\n map[i] = 1 + map[i]!!\n }\n num /= i;\n }\n }\n // 残りが1じゃなかったらそれもカウントする\n if (num != 1) map[num] = 1\n\n return map\n}\n/*\nfun primeFactor(N: Long) : Map {\n val map = hashMapOf();\n var num = N\n (2..(Math.sqrt(N.toDouble()).toLong())).forEach {\n var count = 0L\n while (num % it == 0L) {\n num /= it\n count++\n }\n map[it] = count\n }\n\n if (num != 1L) {\n map[num] = 1\n }\n\n return map\n}\n*/\n\nfun pow(a: Long, b: Long, M: Long): Long {\n var b = b\n var ret: Long = 1\n var tmp = a\n while (b > 0) {\n if (b and 1 == 1L) ret = ret * tmp % M\n tmp = tmp * tmp % M\n b = b shr 1\n }\n return ret\n}\nfun nCk(n: Long, k: Long, M: Long): Long {\n var ret: Long = 1\n val min = Math.min(k, n - k)\n for (i in 1..min) {\n ret = ret * pow(i, (M - 2), M) % M\n }\n for (i in n - min + 1..n) {\n ret = ret * i % M\n }\n return ret\n}", "language": "Kotlin", "metadata": {"date": 1564111364, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Kotlin/s699447956.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s699447956", "user_id": "u861095163"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args : Array) {\n val (N, M) = readLine()!!.split(\" \").map { it.toLong() }\n val fact = primeFactor(M.toInt())\n val MOD = 1000000000+7L\n if (fact.entries.size == 0) {\n println(0)\n return\n }\n var ans = 1L\n fact.entries.forEach {\n // N 個\n ans = ans * nCk(it.value + (N-1), N-1, MOD) % MOD\n }\n println(ans)\n}\n\n\n// O(N^0.5)\n// O(√n)\nfun primeFactor(n: Int) : Map {\n val map = mutableMapOf()\n var num = n;\n for (i in 2..(Math.sqrt(n.toDouble())).toInt()) {\n // iで割れるところまで割り続ける\n while (num % i == 0) {\n if (map[i] == null) {\n map[i] = 1\n } else {\n map[i] = 1 + map[i]!!\n }\n num /= i;\n }\n }\n // 残りが1じゃなかったらそれもカウントする\n if (num != 1) map[num] = 1\n\n return map\n}\n/*\nfun primeFactor(N: Long) : Map {\n val map = hashMapOf();\n var num = N\n (2..(Math.sqrt(N.toDouble()).toLong())).forEach {\n var count = 0L\n while (num % it == 0L) {\n num /= it\n count++\n }\n map[it] = count\n }\n\n if (num != 1L) {\n map[num] = 1\n }\n\n return map\n}\n*/\n\nfun pow(a: Long, b: Long, M: Long): Long {\n var b = b\n var ret: Long = 1\n var tmp = a\n while (b > 0) {\n if (b and 1 == 1L) ret = ret * tmp % M\n tmp = tmp * tmp % M\n b = b shr 1\n }\n return ret\n}\nfun nCk(n: Long, k: Long, M: Long): Long {\n var ret: Long = 1\n val min = Math.min(k, n - k)\n for (i in 1..min) {\n ret = ret * pow(i, (M - 2), M) % M\n }\n for (i in n - min + 1..n) {\n ret = ret * i % M\n }\n return ret\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1778, "cpu_time_ms": 253, "memory_kb": 38008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192994364", "group_id": "codeNet:p03253", "input_text": "import java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val out = PrintWriter(System.out)\n val (n, m) = sc.nextInts(2)\n val mod = 1000000007\n val factors = factors(m)\n val combi = Combination(n + factors.values.sum(), mod)\n var ans = 1\n factors.values.forEach { ans = (ans * combi.get(n + it - 1, it) % mod).toInt() }\n out.println(ans)\n out.close()\n}\n\nfun factors(n: Int): Map {\n val factors = mutableMapOf()\n var tmp = n\n var i = 2\n while (i * i <= tmp) {\n while (tmp % i == 0) {\n factors[i] = factors.getOrElse(i) { 0 } + 1\n tmp /= i\n }\n i++\n }\n if (tmp > 1) factors[tmp] = 1\n return factors\n}\n\nclass Combination(n: Int, private val mod: Int) {\n\n private val fact = LongArray(n + 1)\n private val inv = LongArray(n + 1)\n private val invfact = LongArray(n + 1)\n\n init {\n inv[1] = 1\n for (i in 2 until inv.size) {\n inv[i] = inv[mod % i] * (mod - mod / i) % mod\n }\n\n fact[0] = 1\n invfact[0] = 1\n for (i in 1 until inv.size) {\n fact[i] = i * fact[i - 1] % mod\n invfact[i] = inv[i] * invfact[i - 1] % mod\n }\n }\n\n fun get(n: Int, r: Int): Long {\n return if (n < r) 0 else fact[n] * invfact[n - r] % mod * invfact[r] % mod\n }\n\n}\n\nclass Scanner(private val `in`: InputStream) {\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) return true\n else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) return false\n }\n return true\n }\n\n private fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else -1\n }\n\n private fun isPrintableChar(c: Char): Boolean {\n return c in '!'..'~'\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toChar())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b.toChar())) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n if (b.toChar() in '0'..'9') {\n n *= 10\n n += b - '0'.toByte()\n } else return if (b.toInt() == -1 || !isPrintableChar(b.toChar())) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInts(n: Int): Array {\n return Array(n) { nextInt() }\n }\n\n fun nextIntArray(n: Int): IntArray {\n return IntArray(n) { nextInt() }\n }\n\n fun nextIntArrays(n: Int, m: Int): Array {\n val arrays = Array(m) { IntArray(n) }\n for (i in 0 until n) {\n for (j in 0 until m) {\n arrays[j][i] = nextInt()\n }\n }\n return arrays\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n if (b.toChar() in '0'..'9') {\n n *= 10\n n += (b - '0'.toByte()).toLong()\n } else return if (b.toInt() == -1 || !isPrintableChar(b.toChar())) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLongs(n: Int): Array {\n return Array(n) { nextLong() }\n }\n\n fun nextLongArray(n: Int): LongArray {\n return LongArray(n) { nextLong() }\n }\n\n fun nextLongArrays(n: Int, m: Int): Array {\n val arrays = Array(m) { LongArray(n) }\n for (i in 0 until n) {\n for (j in 0 until m) {\n arrays[j][i] = nextLong()\n }\n }\n return arrays\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1537761766, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Kotlin/s192994364.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192994364", "user_id": "u253203109"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.IOException\nimport java.io.InputStream\nimport java.io.PrintWriter\nimport java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val out = PrintWriter(System.out)\n val (n, m) = sc.nextInts(2)\n val mod = 1000000007\n val factors = factors(m)\n val combi = Combination(n + factors.values.sum(), mod)\n var ans = 1\n factors.values.forEach { ans = (ans * combi.get(n + it - 1, it) % mod).toInt() }\n out.println(ans)\n out.close()\n}\n\nfun factors(n: Int): Map {\n val factors = mutableMapOf()\n var tmp = n\n var i = 2\n while (i * i <= tmp) {\n while (tmp % i == 0) {\n factors[i] = factors.getOrElse(i) { 0 } + 1\n tmp /= i\n }\n i++\n }\n if (tmp > 1) factors[tmp] = 1\n return factors\n}\n\nclass Combination(n: Int, private val mod: Int) {\n\n private val fact = LongArray(n + 1)\n private val inv = LongArray(n + 1)\n private val invfact = LongArray(n + 1)\n\n init {\n inv[1] = 1\n for (i in 2 until inv.size) {\n inv[i] = inv[mod % i] * (mod - mod / i) % mod\n }\n\n fact[0] = 1\n invfact[0] = 1\n for (i in 1 until inv.size) {\n fact[i] = i * fact[i - 1] % mod\n invfact[i] = inv[i] * invfact[i - 1] % mod\n }\n }\n\n fun get(n: Int, r: Int): Long {\n return if (n < r) 0 else fact[n] * invfact[n - r] % mod * invfact[r] % mod\n }\n\n}\n\nclass Scanner(private val `in`: InputStream) {\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) return true\n else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n if (buflen <= 0) return false\n }\n return true\n }\n\n private fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else -1\n }\n\n private fun isPrintableChar(c: Char): Boolean {\n return c in '!'..'~'\n }\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toChar())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (isPrintableChar(b.toChar())) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n if (b.toChar() in '0'..'9') {\n n *= 10\n n += b - '0'.toByte()\n } else return if (b.toInt() == -1 || !isPrintableChar(b.toChar())) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInts(n: Int): Array {\n return Array(n) { nextInt() }\n }\n\n fun nextIntArray(n: Int): IntArray {\n return IntArray(n) { nextInt() }\n }\n\n fun nextIntArrays(n: Int, m: Int): Array {\n val arrays = Array(m) { IntArray(n) }\n for (i in 0 until n) {\n for (j in 0 until m) {\n arrays[j][i] = nextInt()\n }\n }\n return arrays\n }\n\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n: Long = 0\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n if (b.toChar() in '0'..'9') {\n n *= 10\n n += (b - '0'.toByte()).toLong()\n } else return if (b.toInt() == -1 || !isPrintableChar(b.toChar())) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextLongs(n: Int): Array {\n return Array(n) { nextLong() }\n }\n\n fun nextLongArray(n: Int): LongArray {\n return LongArray(n) { nextLong() }\n }\n\n fun nextLongArrays(n: Int, m: Int): Array {\n val arrays = Array(m) { LongArray(n) }\n for (i in 0 until n) {\n for (j in 0 until m) {\n arrays[j][i] = nextLong()\n }\n }\n return arrays\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4908, "cpu_time_ms": 199, "memory_kb": 33440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s980147843", "group_id": "codeNet:p03264", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextInt()\n val odd = (k + 1) / 2\n val even = k / 2\n println(odd * even)\n}", "language": "Kotlin", "metadata": {"date": 1583368205, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03264/input.txt", "sample_output_relpath": "derived/input_output/data/p03264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03264/Kotlin/s980147843.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980147843", "user_id": "u733811860"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val k = sc.nextInt()\n val odd = (k + 1) / 2\n val even = k / 2\n println(odd * even)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "sample_input": "3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03264", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 180, "memory_kb": 29464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s780665058", "group_id": "codeNet:p03264", "input_text": "fun main(args: Array) {\n a108(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\n\nfun a108(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val num = args[0].toInt()\n fun square(number: Int): Int = number * number\n println(if (num % 2 == 0) square(num / 2) else num / 2 * (num / 2 + 1))\n}", "language": "Kotlin", "metadata": {"date": 1540621513, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03264/input.txt", "sample_output_relpath": "derived/input_output/data/p03264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03264/Kotlin/s780665058.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s780665058", "user_id": "u227166381"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n a108(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\n\nfun a108(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val num = args[0].toInt()\n fun square(number: Int): Int = number * number\n println(if (num % 2 == 0) square(num / 2) else num / 2 * (num / 2 + 1))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "sample_input": "3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03264", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 610, "cpu_time_ms": 211, "memory_kb": 33700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s606696074", "group_id": "codeNet:p03273", "input_text": "import java.util.*\n\nval sc = Scanner(System.`in`)\nval H = sc.nextInt()\nval W = sc.nextInt()\n\nfun main(args: Array) {\n var a = Array(H) { \"\" }\n for (i in 0 until H) {\n a[i] = sc.next()\n }\n\n for (i in 0 until 4) {\n a = a.filter { it.contains('#') }.toTypedArray()\n a = rotated(a)\n }\n println(a.joinToString(\"\\n\"))\n}\n\n\nfun rotated(a: Array): Array {\n val result = Array(a[0].length) { \"\" }\n\n for (i in 0 until a[0].length) {\n for (j in 0 until a.size) {\n result[i] += a[a.size - 1 - j][i].toString()\n }\n }\n return result\n}\n", "language": "Kotlin", "metadata": {"date": 1541906610, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Kotlin/s606696074.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s606696074", "user_id": "u323680411"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "import java.util.*\n\nval sc = Scanner(System.`in`)\nval H = sc.nextInt()\nval W = sc.nextInt()\n\nfun main(args: Array) {\n var a = Array(H) { \"\" }\n for (i in 0 until H) {\n a[i] = sc.next()\n }\n\n for (i in 0 until 4) {\n a = a.filter { it.contains('#') }.toTypedArray()\n a = rotated(a)\n }\n println(a.joinToString(\"\\n\"))\n}\n\n\nfun rotated(a: Array): Array {\n val result = Array(a[0].length) { \"\" }\n\n for (i in 0 until a[0].length) {\n for (j in 0 until a.size) {\n result[i] += a[a.size - 1 - j][i].toString()\n }\n }\n return result\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 403, "memory_kb": 48020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s633274604", "group_id": "codeNet:p03274", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val x = (0 until n).map { sc.next().toLong() }\n println(problem107c(n, k, x))\n}\n\nfun problem107c(n: Int, k: Int, x: List): Long {\n var min = Long.MAX_VALUE\n for (i in 0 .. n - k) {\n if (i < 0 && x[i + 1] < 0) continue\n if (i > 0 && x[i - 1] > 0) continue\n// debugLog(i, x[i], x[i + k - 1], Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1]))\n if (x[i] > 0) {\n min = Math.min(min, x[i + k - 1])\n continue\n }\n if (x[i + k - 1] < 0) {\n min = Math.min(min, Math.abs(x[k]))\n continue\n }\n min = listOf(min, Math.abs(x[i] - x[i + k - 1] * 2), Math.abs(x[i] * 2 - x[i + k - 1])).min()!!\n }\n return min\n}\n", "language": "Kotlin", "metadata": {"date": 1586675193, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03274/input.txt", "sample_output_relpath": "derived/input_output/data/p03274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03274/Kotlin/s633274604.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s633274604", "user_id": "u073232808"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val x = (0 until n).map { sc.next().toLong() }\n println(problem107c(n, k, x))\n}\n\nfun problem107c(n: Int, k: Int, x: List): Long {\n var min = Long.MAX_VALUE\n for (i in 0 .. n - k) {\n if (i < 0 && x[i + 1] < 0) continue\n if (i > 0 && x[i - 1] > 0) continue\n// debugLog(i, x[i], x[i + k - 1], Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1]))\n if (x[i] > 0) {\n min = Math.min(min, x[i + k - 1])\n continue\n }\n if (x[i + k - 1] < 0) {\n min = Math.min(min, Math.abs(x[k]))\n continue\n }\n min = listOf(min, Math.abs(x[i] - x[i + k - 1] * 2), Math.abs(x[i] * 2 - x[i + k - 1])).min()!!\n }\n return min\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03274", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 875, "cpu_time_ms": 774, "memory_kb": 53008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s308772373", "group_id": "codeNet:p03274", "input_text": "fun main(args: Array) {\n val (N, K) = readInputLine().split(\" \").map{it.toInt()}\n \n val xs = readInputLine().split(\" \").map{it.toInt()}.toIntArray()\n \n var l = 0\n var r = K - 1\n \n var ans = distance(xs, l, r)\n\n while (r < N - 1) {\n val nextDistance = distance(xs, l + 1, r + 1)\n if (nextDistance < ans) {\n ans = nextDistance\n l++\n r++\n }\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun distance(xs: IntArray, l: Int, r: Int): Int {\n return if (xs[l] <= 0 && xs[r] <= 0) -xs[l] else if (xs[l] >= 0 && xs[r] >= 0) xs[r] else xs[r] - xs[l] * 2\n}\n", "language": "Kotlin", "metadata": {"date": 1565663202, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03274/input.txt", "sample_output_relpath": "derived/input_output/data/p03274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03274/Kotlin/s308772373.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s308772373", "user_id": "u505558493"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readInputLine().split(\" \").map{it.toInt()}\n \n val xs = readInputLine().split(\" \").map{it.toInt()}.toIntArray()\n \n var l = 0\n var r = K - 1\n \n var ans = distance(xs, l, r)\n\n while (r < N - 1) {\n val nextDistance = distance(xs, l + 1, r + 1)\n if (nextDistance < ans) {\n ans = nextDistance\n l++\n r++\n }\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n\nfun distance(xs: IntArray, l: Int, r: Int): Int {\n return if (xs[l] <= 0 && xs[r] <= 0) -xs[l] else if (xs[l] >= 0 && xs[r] >= 0) xs[r] else xs[r] - xs[l] * 2\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03274", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 679, "cpu_time_ms": 2111, "memory_kb": 51848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s870605382", "group_id": "codeNet:p03274", "input_text": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var a = 999999999\n for (i in 0 .. x - y){\n a = Math.min(a, Math.abs(l[i + y - 1]) + Math.abs(l[i + y - 1] - l[i]))\n a = Math.min(a, Math.abs(l[i]) + Math.abs(l[i + y - 1] - l[i]))\n }\n println(a)\n}", "language": "Kotlin", "metadata": {"date": 1547144084, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03274/input.txt", "sample_output_relpath": "derived/input_output/data/p03274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03274/Kotlin/s870605382.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s870605382", "user_id": "u227189389"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var a = 999999999\n for (i in 0 .. x - y){\n a = Math.min(a, Math.abs(l[i + y - 1]) + Math.abs(l[i + y - 1] - l[i]))\n a = Math.min(a, Math.abs(l[i]) + Math.abs(l[i + y - 1] - l[i]))\n }\n println(a)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03274", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 370, "cpu_time_ms": 514, "memory_kb": 51724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s933446576", "group_id": "codeNet:p03274", "input_text": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var a = 99999999\n var tmpa = 0\n for (i in 0 .. x - y){\n tmpa = Math.min(Math.abs(l[i]) + Math.abs(l[i + y - 1] - l[i]), Math.abs(l[i + y - 1]) + Math.abs(l[i + y - 1] - l[i]))\n a = Math.min(a, tmpa)\n }\n println(a)\n}", "language": "Kotlin", "metadata": {"date": 1547143325, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03274/input.txt", "sample_output_relpath": "derived/input_output/data/p03274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03274/Kotlin/s933446576.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s933446576", "user_id": "u227189389"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, y) = readLine()!!.split(\" \").map { it.toInt() }\n val l = readLine()!!.split(\" \").map { it.toInt() }\n var a = 99999999\n var tmpa = 0\n for (i in 0 .. x - y){\n tmpa = Math.min(Math.abs(l[i]) + Math.abs(l[i + y - 1] - l[i]), Math.abs(l[i + y - 1]) + Math.abs(l[i + y - 1] - l[i]))\n a = Math.min(a, tmpa)\n }\n println(a)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03274", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 392, "cpu_time_ms": 521, "memory_kb": 49920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s802689228", "group_id": "codeNet:p03275", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n // iが中央値 i以下の数 - i強の数 > 0 の値で最小\n\n var ng = a.min()!! - 1\n var ok = a.max()!!\n val all = n.toLong() * (n + 1) / 2\n while (ok - ng > 1) {\n val med = (ok + ng) / 2\n var sum = 0\n val bit = FenwickTree(2 * n + 1)\n bit.add(n, 1)\n var cnt = 0L\n for (i in 0 until n) {\n sum += if (a[i] <= med) 1 else -1\n cnt += bit.sum(sum + n)\n bit.add(sum + n, 1)\n }\n\n if (cnt > all - cnt) {\n ok = med\n } else {\n ng = med\n }\n }\n\n println(ok)\n }\n}\n\nclass FenwickTree(private val size: Int) {\n private val tree = Array(size + 1) { 0 }\n\n // a[i]にnを加算\n fun add(i: Int, n: Int) {\n var t = i + 1\n while (t <= size) {\n tree[t] += n\n t += (t and (-t))\n }\n }\n\n // [0,i)の合計を求める\n fun sum(i: Int): Int {\n var result = 0\n var t = i\n while (t > 0) {\n result += tree[t]\n t -= (t and (-t))\n }\n return result\n }\n}\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582439198, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03275.html", "problem_id": "p03275", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03275/input.txt", "sample_output_relpath": "derived/input_output/data/p03275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03275/Kotlin/s802689228.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s802689228", "user_id": "u194412908"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }\n\n // iが中央値 i以下の数 - i強の数 > 0 の値で最小\n\n var ng = a.min()!! - 1\n var ok = a.max()!!\n val all = n.toLong() * (n + 1) / 2\n while (ok - ng > 1) {\n val med = (ok + ng) / 2\n var sum = 0\n val bit = FenwickTree(2 * n + 1)\n bit.add(n, 1)\n var cnt = 0L\n for (i in 0 until n) {\n sum += if (a[i] <= med) 1 else -1\n cnt += bit.sum(sum + n)\n bit.add(sum + n, 1)\n }\n\n if (cnt > all - cnt) {\n ok = med\n } else {\n ng = med\n }\n }\n\n println(ok)\n }\n}\n\nclass FenwickTree(private val size: Int) {\n private val tree = Array(size + 1) { 0 }\n\n // a[i]にnを加算\n fun add(i: Int, n: Int) {\n var t = i + 1\n while (t <= size) {\n tree[t] += n\n t += (t and (-t))\n }\n }\n\n // [0,i)の合計を求める\n fun sum(i: Int): Int {\n var result = 0\n var t = i\n while (t > 0) {\n result += tree[t]\n t -= (t and (-t))\n }\n return result\n }\n}\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "sample_input": "3\n10 30 20\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03275", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4015, "cpu_time_ms": 594, "memory_kb": 116116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s612517861", "group_id": "codeNet:p03280", "input_text": "fun main(args:Array) {\n val ans = readLine()!!.split(\" \").map { it.toInt() - 1 }.let { it[0]*it[1] }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1575412227, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03280/input.txt", "sample_output_relpath": "derived/input_output/data/p03280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03280/Kotlin/s612517861.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s612517861", "user_id": "u269969976"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args:Array) {\n val ans = readLine()!!.split(\" \").map { it.toInt() - 1 }.let { it[0]*it[1] }\n println(ans)\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "sample_input": "2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03280", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 241, "memory_kb": 36152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s351318354", "group_id": "codeNet:p03280", "input_text": "fun main(args: Array) {\n\tval (a, b) = readLine()!!.split(\" \").map(String::toInt)\n\tprintln((a - 1) * (b - 1))\n}\n", "language": "Kotlin", "metadata": {"date": 1537321922, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03280/input.txt", "sample_output_relpath": "derived/input_output/data/p03280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03280/Kotlin/s351318354.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s351318354", "user_id": "u323680411"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n\tval (a, b) = readLine()!!.split(\" \").map(String::toInt)\n\tprintln((a - 1) * (b - 1))\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "sample_input": "2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03280", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 239, "memory_kb": 38000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s532353564", "group_id": "codeNet:p03281", "input_text": "import kotlin.math.sqrt\n\nfun main() {\n val nmk = nextInt()\n val ans = solve(nmk)\n println(ans)\n}\n\nfun solve(nmk: Int): Int {\n val a = (1..nmk).filter { it % 2 != 0 }.filter {\n (1..nmk).filter { i -> it % i == 0 }.size == 8\n }\n\n return a.size\n\n}\n\nfun nextInt(): Int {\n return readLine()!!.toInt()\n}", "language": "Kotlin", "metadata": {"date": 1598392198, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Kotlin/s532353564.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s532353564", "user_id": "u015874590"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import kotlin.math.sqrt\n\nfun main() {\n val nmk = nextInt()\n val ans = solve(nmk)\n println(ans)\n}\n\nfun solve(nmk: Int): Int {\n val a = (1..nmk).filter { it % 2 != 0 }.filter {\n (1..nmk).filter { i -> it % i == 0 }.size == 8\n }\n\n return a.size\n\n}\n\nfun nextInt(): Int {\n return readLine()!!.toInt()\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 106, "memory_kb": 34744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s924552310", "group_id": "codeNet:p03281", "input_text": "fun main(args:Array):Unit {\n val sc = java.util.Scanner(System.`in`)\n val n = sc.nextInt()\n println((1..n).filter { it % 2 == 1 }.filter { v ->\n (1..v).asSequence().filter { v % it == 0 }.count() == 8\n }.count())\n}", "language": "Kotlin", "metadata": {"date": 1558694873, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Kotlin/s924552310.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s924552310", "user_id": "u059223549"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args:Array):Unit {\n val sc = java.util.Scanner(System.`in`)\n val n = sc.nextInt()\n println((1..n).filter { it % 2 == 1 }.filter { v ->\n (1..v).asSequence().filter { v % it == 0 }.count() == 8\n }.count())\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 214, "memory_kb": 31648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s532099434", "group_id": "codeNet:p03282", "input_text": "fun main(args: Array) {\n val S = next()\n val K = nextLong()\n var n = 0\n while (n < S.length && n.toLong() < K) {\n if (S[n] != '1') {\n println(S[n])\n return\n }\n n += 1\n }\n println(1)\n}\n\nfun next() = readLine()!!\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1584112198, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03282/input.txt", "sample_output_relpath": "derived/input_output/data/p03282/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03282/Kotlin/s532099434.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s532099434", "user_id": "u043150661"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val S = next()\n val K = nextLong()\n var n = 0\n while (n < S.length && n.toLong() < K) {\n if (S[n] != '1') {\n println(S[n])\n return\n }\n n += 1\n }\n println(1)\n}\n\nfun next() = readLine()!!\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "sample_input": "1214\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03282", "source_text": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 414, "cpu_time_ms": 199, "memory_kb": 29784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s351887109", "group_id": "codeNet:p03282", "input_text": "fun main(args: Array) {\n val s = readLine()\n val k = readLine()\n\n try {\n if (s!!.startsWith(\"1\".repeat(k!!.toInt()))) {\n println(\"1\")\n return\n }\n } catch (e: Exception) {\n\n } finally {\n val t = s!!.filter { it != '1' }\n println(t[0])\n }\n}", "language": "Kotlin", "metadata": {"date": 1535102983, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03282/input.txt", "sample_output_relpath": "derived/input_output/data/p03282/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03282/Kotlin/s351887109.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s351887109", "user_id": "u471898432"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()\n val k = readLine()\n\n try {\n if (s!!.startsWith(\"1\".repeat(k!!.toInt()))) {\n println(\"1\")\n return\n }\n } catch (e: Exception) {\n\n } finally {\n val t = s!!.filter { it != '1' }\n println(t[0])\n }\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "sample_input": "1214\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03282", "source_text": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 207, "memory_kb": 33412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s250488884", "group_id": "codeNet:p03284", "input_text": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n println(n % k)\n}", "language": "Kotlin", "metadata": {"date": 1555305852, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/Kotlin/s250488884.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s250488884", "user_id": "u845620905"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map(String::toInt)\n println(n % k)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 236, "memory_kb": 38044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s778567048", "group_id": "codeNet:p03284", "input_text": "fun main(args: Array) {\n val (n,k) = readLine()!!.split(\" \").map{it.toInt()}\n if(n%k==0){\n println(0)\n }else{\n println(1)\n }\n}", "language": "Kotlin", "metadata": {"date": 1540592217, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/Kotlin/s778567048.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s778567048", "user_id": "u914096045"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,k) = readLine()!!.split(\" \").map{it.toInt()}\n if(n%k==0){\n println(0)\n }else{\n println(1)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 160, "cpu_time_ms": 233, "memory_kb": 36080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s126987732", "group_id": "codeNet:p03284", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n println(if (N % K == 0) 0 else 1)\n}", "language": "Kotlin", "metadata": {"date": 1536382851, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/Kotlin/s126987732.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s126987732", "user_id": "u398846051"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map(String::toInt)\n println(if (N % K == 0) 0 else 1)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 240, "memory_kb": 37988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s294650180", "group_id": "codeNet:p03284", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n println(Math.min(1, (N % K)))\n}", "language": "Kotlin", "metadata": {"date": 1534035897, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/Kotlin/s294650180.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s294650180", "user_id": "u771276989"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map { it.toInt() }\n println(Math.min(1, (N % K)))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 127, "cpu_time_ms": 305, "memory_kb": 37904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s271646713", "group_id": "codeNet:p03285", "input_text": "fun main(args : Array) {\n var price = readLine()!!.toInt()\n\n var ok = false\n var current = 0\n while (current <= price){\n if ((price - current) % 7 == 0){\n ok = true\n break\n }\n current += 4\n }\n if (ok){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1567173985, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03285/input.txt", "sample_output_relpath": "derived/input_output/data/p03285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03285/Kotlin/s271646713.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271646713", "user_id": "u714769076"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args : Array) {\n var price = readLine()!!.toInt()\n\n var ok = false\n var current = 0\n while (current <= price){\n if ((price - current) % 7 == 0){\n ok = true\n break\n }\n current += 4\n }\n if (ok){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 202, "memory_kb": 31736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s854485852", "group_id": "codeNet:p03285", "input_text": "fun main(args : Array) {\n print(readLine()!!.toInt().let { n -> if ((0..n).any { it % 4 == 0 && (n - it) % 7 == 0 }) \"Yes\" else \"No\" })\n}", "language": "Kotlin", "metadata": {"date": 1538591879, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03285/input.txt", "sample_output_relpath": "derived/input_output/data/p03285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03285/Kotlin/s854485852.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s854485852", "user_id": "u384476909"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args : Array) {\n print(readLine()!!.toInt().let { n -> if ((0..n).any { it % 4 == 0 && (n - it) % 7 == 0 }) \"Yes\" else \"No\" })\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 146, "cpu_time_ms": 202, "memory_kb": 31772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s194046557", "group_id": "codeNet:p03290", "input_text": "import java.math.*\n\nfun main(args: Array) {\n var (D, G) = readInputLine().split(\" \").map{it.toInt()}\n G /= 100\n \n // (問題数, ボーナス)\n val problems = Array(D, {Pair(0, 0)})\n \n for (i in 0 until D) {\n val tmp = readInputLine().split(\" \").map{it.toInt()}\n problems[i] = Pair(tmp[0], tmp[1] / 100)\n }\n\n var ans = Int.MAX_VALUE\n \n for (i in 0 until (1 shl D)) {\n var score = 0\n var cnt = 0\n for (j in 0 until D) {\n if (i and (1 shl j) != 0) {\n score += problems[j].first * (j + 1) + problems[j].second\n cnt += problems[j].first\n }\n }\n\n if (score >= G) {\n ans = Math.min(ans, cnt)\n continue\n }\n \n for (j in D - 1 downTo 0) {\n if (i and (1 shl j) != 0) {\n continue\n }\n for (k in 1 until problems[j].first) {\n score += j + 1\n cnt++\n if (score >= G) {\n break\n }\n }\n if (score >= G) {\n break\n }\n }\n \n if (score >= G) {\n ans = Math.min(ans, cnt)\n }\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565450527, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03290/input.txt", "sample_output_relpath": "derived/input_output/data/p03290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03290/Kotlin/s194046557.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194046557", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n var (D, G) = readInputLine().split(\" \").map{it.toInt()}\n G /= 100\n \n // (問題数, ボーナス)\n val problems = Array(D, {Pair(0, 0)})\n \n for (i in 0 until D) {\n val tmp = readInputLine().split(\" \").map{it.toInt()}\n problems[i] = Pair(tmp[0], tmp[1] / 100)\n }\n\n var ans = Int.MAX_VALUE\n \n for (i in 0 until (1 shl D)) {\n var score = 0\n var cnt = 0\n for (j in 0 until D) {\n if (i and (1 shl j) != 0) {\n score += problems[j].first * (j + 1) + problems[j].second\n cnt += problems[j].first\n }\n }\n\n if (score >= G) {\n ans = Math.min(ans, cnt)\n continue\n }\n \n for (j in D - 1 downTo 0) {\n if (i and (1 shl j) != 0) {\n continue\n }\n for (k in 1 until problems[j].first) {\n score += j + 1\n cnt++\n if (score >= G) {\n break\n }\n }\n if (score >= G) {\n break\n }\n }\n \n if (score >= G) {\n ans = Math.min(ans, cnt)\n }\n }\n \n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1334, "cpu_time_ms": 267, "memory_kb": 37992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s653270498", "group_id": "codeNet:p03290", "input_text": "data class Problems(var size: Int, val bonus: Int, val score: Int, val totalScore: Int)\n\nfun main(args : Array) {\n val (D, G) = readLine()!!.split(\" \").map { it.toInt() }\n val problemSizeAndBonusScoreAndSingleScoreAndTotal = emptyList().toMutableList()\n // O(D) = O(10)\n for (i in 1..D) {\n val (p, c) = readLine()!!.split(\" \").map { it.toInt() }\n val score = 100 * i\n val total = score * p + c\n problemSizeAndBonusScoreAndSingleScoreAndTotal.add(Problems(p, c, score, total))\n }\n\n var a = emptyList>().toMutableList()\n\n for (i in 0..(problemSizeAndBonusScoreAndSingleScoreAndTotal.size - 1)) {\n val elm = problemSizeAndBonusScoreAndSingleScoreAndTotal.get(i)\n a.add(Triple(i, elm.totalScore, true))\n a.add(Triple(i, elm.score, false))\n }\n\n val set = setOf().toMutableSet()\n var answer = 0\n var objective = G\n\n while (objective > 0) {\n\n // sort by current efficiency\n a.sortByDescending {\n if (it.third) {\n val origin = problemSizeAndBonusScoreAndSingleScoreAndTotal.get(it.first)\n if (origin.size == 0) {\n Int.MIN_VALUE\n } else {\n Math.min(objective, it.second) / origin.size\n }\n } else {\n it.second\n }\n }\n\n // get top\n // if that is bunch type,\n val top = a.first()\n\n if (set.contains(top.first)) {\n } else {\n val origin = problemSizeAndBonusScoreAndSingleScoreAndTotal.get(top.first)\n if (top.third) {\n if (objective <= origin.totalScore - origin.bonus) {\n while (origin.size > 0 && objective > 0) {\n objective -= origin.score\n answer++\n origin.size--\n }\n } else {\n objective -= origin.totalScore\n answer += origin.size\n origin.size = 0\n }\n } else {\n while (origin.size > 0 && objective > 0) {\n objective -= origin.score\n answer++\n origin.size--\n }\n }\n\n set.add(top.first)\n }\n a = a.drop(1).toMutableList()\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1533678492, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03290/input.txt", "sample_output_relpath": "derived/input_output/data/p03290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03290/Kotlin/s653270498.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s653270498", "user_id": "u861095163"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "data class Problems(var size: Int, val bonus: Int, val score: Int, val totalScore: Int)\n\nfun main(args : Array) {\n val (D, G) = readLine()!!.split(\" \").map { it.toInt() }\n val problemSizeAndBonusScoreAndSingleScoreAndTotal = emptyList().toMutableList()\n // O(D) = O(10)\n for (i in 1..D) {\n val (p, c) = readLine()!!.split(\" \").map { it.toInt() }\n val score = 100 * i\n val total = score * p + c\n problemSizeAndBonusScoreAndSingleScoreAndTotal.add(Problems(p, c, score, total))\n }\n\n var a = emptyList>().toMutableList()\n\n for (i in 0..(problemSizeAndBonusScoreAndSingleScoreAndTotal.size - 1)) {\n val elm = problemSizeAndBonusScoreAndSingleScoreAndTotal.get(i)\n a.add(Triple(i, elm.totalScore, true))\n a.add(Triple(i, elm.score, false))\n }\n\n val set = setOf().toMutableSet()\n var answer = 0\n var objective = G\n\n while (objective > 0) {\n\n // sort by current efficiency\n a.sortByDescending {\n if (it.third) {\n val origin = problemSizeAndBonusScoreAndSingleScoreAndTotal.get(it.first)\n if (origin.size == 0) {\n Int.MIN_VALUE\n } else {\n Math.min(objective, it.second) / origin.size\n }\n } else {\n it.second\n }\n }\n\n // get top\n // if that is bunch type,\n val top = a.first()\n\n if (set.contains(top.first)) {\n } else {\n val origin = problemSizeAndBonusScoreAndSingleScoreAndTotal.get(top.first)\n if (top.third) {\n if (objective <= origin.totalScore - origin.bonus) {\n while (origin.size > 0 && objective > 0) {\n objective -= origin.score\n answer++\n origin.size--\n }\n } else {\n objective -= origin.totalScore\n answer += origin.size\n origin.size = 0\n }\n } else {\n while (origin.size > 0 && objective > 0) {\n objective -= origin.score\n answer++\n origin.size--\n }\n }\n\n set.add(top.first)\n }\n a = a.drop(1).toMutableList()\n }\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2439, "cpu_time_ms": 245, "memory_kb": 37956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s300978514", "group_id": "codeNet:p03291", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val scan = FastScanner()\n val s = scan.next()\n val n = s.length\n val dp = Array(n+1){Array(4){co(0)}}\n dp[0][0] = co(1)\n for (i in 0 until n) {\n val k = if (s[i] == '?') 3L else 1L\n for (j in 0..3) {\n dp[i+1][j] += dp[i][j] * co(k)\n }\n if (s[i] == '?') {\n for (j in 0 until 3) {\n dp[i+1][j+1] += dp[i][j]\n }\n } else {\n val j = s[i].toInt() - 'A'.toInt()\n dp[i+1][j+1] += dp[i][j]\n }\n }\n println(dp[n][3].n)\n}\n\nprivate val M = 1000000007L\n\nfun co(n: Long) = Co(n % M)\n\ndata class Co(val n: Long) {\n operator fun plus(other: Co): Co {\n return co(n + other.n)\n }\n operator fun minus(other: Co): Co {\n return co((n - other.n) % M + M)\n }\n operator fun times(other: Co): Co {\n return co(n * other.n)\n }\n operator fun div(other: Co): Co {\n return this * other.pow(M - 2)\n }\n fun pow(k_: Long): Co {\n var k = k_\n var a = this\n var res = co(1)\n while (k > 0) {\n if (k.and(1) == 1L) {\n res *= a\n }\n a *= a\n k = k.shr(1)\n }\n return res\n }\n}\n\nclass FastScanner {\n private val printable = 33..126\n val `in` = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = `in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun nextDouble(): Double {\n return next().toDouble()\n }\n}", "language": "Kotlin", "metadata": {"date": 1564519731, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03291.html", "problem_id": "p03291", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03291/input.txt", "sample_output_relpath": "derived/input_output/data/p03291/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03291/Kotlin/s300978514.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s300978514", "user_id": "u095834727"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val scan = FastScanner()\n val s = scan.next()\n val n = s.length\n val dp = Array(n+1){Array(4){co(0)}}\n dp[0][0] = co(1)\n for (i in 0 until n) {\n val k = if (s[i] == '?') 3L else 1L\n for (j in 0..3) {\n dp[i+1][j] += dp[i][j] * co(k)\n }\n if (s[i] == '?') {\n for (j in 0 until 3) {\n dp[i+1][j+1] += dp[i][j]\n }\n } else {\n val j = s[i].toInt() - 'A'.toInt()\n dp[i+1][j+1] += dp[i][j]\n }\n }\n println(dp[n][3].n)\n}\n\nprivate val M = 1000000007L\n\nfun co(n: Long) = Co(n % M)\n\ndata class Co(val n: Long) {\n operator fun plus(other: Co): Co {\n return co(n + other.n)\n }\n operator fun minus(other: Co): Co {\n return co((n - other.n) % M + M)\n }\n operator fun times(other: Co): Co {\n return co(n * other.n)\n }\n operator fun div(other: Co): Co {\n return this * other.pow(M - 2)\n }\n fun pow(k_: Long): Co {\n var k = k_\n var a = this\n var res = co(1)\n while (k > 0) {\n if (k.and(1) == 1L) {\n res *= a\n }\n a *= a\n k = k.shr(1)\n }\n return res\n }\n}\n\nclass FastScanner {\n private val printable = 33..126\n val `in` = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = `in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun nextDouble(): Double {\n return next().toDouble()\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "sample_input": "A??C\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03291", "source_text": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3175, "cpu_time_ms": 464, "memory_kb": 80176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s127036024", "group_id": "codeNet:p03292", "input_text": "fun main(args: Array) {\n\tval a = readLine()!!.split(\" \").map { it.toInt() }\n\tval sorted_a = a.sorted()\n\n\tprintln(sorted_a[2] - sorted_a[0])\n}\n", "language": "Kotlin", "metadata": {"date": 1537324065, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03292/input.txt", "sample_output_relpath": "derived/input_output/data/p03292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03292/Kotlin/s127036024.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127036024", "user_id": "u323680411"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n\tval a = readLine()!!.split(\" \").map { it.toInt() }\n\tval sorted_a = a.sorted()\n\n\tprintln(sorted_a[2] - sorted_a[0])\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 233, "memory_kb": 37612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s907910757", "group_id": "codeNet:p03295", "input_text": "import java.util.*\nimport kotlin.math.max\n\nfun main() = abc103d()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc103d() = IO_abc103d().exec {\n val (n, m) = readIntList(2)\n val requests = readList(m) { readInt() to readInt() }\n\n var cutOnLeft = 0\n val pQueue = PriorityQueue>(kotlin.Comparator { o1, o2 ->\n o1.second.compareTo(o2.second)\n })\n pQueue.addAll(requests)\n\n var answer = 0\n\n while (pQueue.isNotEmpty()) {\n val (from, to) = pQueue.poll()\n if (from < cutOnLeft) continue\n cutOnLeft = max(cutOnLeft, to)\n answer++\n }\n\n println(answer)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"ClassName\", \"SpellCheckingInspection\", \"ConvertToStringTemplate\", \"MemberVisibilityCanBePrivate\")\nprivate class IO_abc103d(private val separator: String = System.lineSeparator()) {\n private val input = System.`in`\n private val buffer = ByteArray(1024)\n private var pointer = 0\n private var bufferLength = 0\n private val sb = StringBuilder()\n private fun Byte.isPrintable() = this in 33..126\n private fun Byte.isNumeric() = this in '0'.toByte()..'9'.toByte()\n private fun Byte.toNumVal() = if (this.isNumeric()) this - '0'.toByte() else error(\"$this is not numeric\")\n\n private fun hasNextByte(): Boolean {\n return if (pointer < bufferLength) true else {\n pointer = 0\n bufferLength = input.read(buffer)\n bufferLength > 0\n }\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[pointer++] else -1\n private fun skipUnprintable() = run { while (hasNextByte() && !buffer[pointer].isPrintable()) pointer++ }\n private fun hasNext(): Boolean = run { skipUnprintable() }.run { hasNextByte() }\n private fun hasNextOrError() = if (!hasNext()) error(\"has no next element.\") else Unit\n\n fun readString(): String {\n hasNextOrError()\n val sb = StringBuilder()\n var b = readByte()\n while (b.isPrintable()) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun readLong(): Long {\n hasNextOrError()\n var n = 0L\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n if (!b.isNumeric()) error(\"$b is not numeric.\")\n while (true) {\n when {\n b.isNumeric() -> n = n * 10 + b.toNumVal()\n b.toInt() == -1 || !b.isPrintable() -> return if (negative) -n else n\n else -> error(\"failed to parse. [n=$n, b=$b]\")\n }\n b = readByte()\n }\n }\n\n fun readInt() = readLong()\n .let { if (it in Int.MIN_VALUE..Int.MAX_VALUE) it.toInt() else error(\"$it is not in range of Int.\") }\n\n fun readDouble(): Double {\n var n = 0.0\n var div = 1.0\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n do n = n * 10 + b.toNumVal()\n while (run { b = readByte() }.run { b.isNumeric() })\n if (b == '.'.toByte()) {\n while (run { b = readByte() }.run { b.isNumeric() })\n n += b.toNumVal() / (run { div *= 10 }.run { div })\n }\n return if (negative) -n else n\n }\n\n fun readStringList(size: Int) = readList(size) { readString() }\n fun readIntList(size: Int) = readList(size) { readInt() }\n fun readLongList(size: Int) = readList(size) { readLong() }\n fun readDoubleList(size: Int) = readList(size) { readDouble() }\n fun readIntArray(size: Int) = IntArray(size) { readInt() }\n fun readLongArray(size: Int) = LongArray(size) { readLong() }\n fun readDoubleArray(size: Int) = DoubleArray(size) { readDouble() }\n inline fun readArray(size: Int, init: () -> T) = Array(size) { init() }\n inline fun readList(size: Int, init: () -> T) = List(size) { init() }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n\n fun exec(code: IO_abc103d.() -> Unit) = run {\n Thread(null, { code() }, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n }.run { kotlin.io.print(sb) }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "language": "Kotlin", "metadata": {"date": 1595826127, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03295/input.txt", "sample_output_relpath": "derived/input_output/data/p03295/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03295/Kotlin/s907910757.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s907910757", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.max\n\nfun main() = abc103d()\n\n@OptIn(ExperimentalStdlibApi::class)\nfun abc103d() = IO_abc103d().exec {\n val (n, m) = readIntList(2)\n val requests = readList(m) { readInt() to readInt() }\n\n var cutOnLeft = 0\n val pQueue = PriorityQueue>(kotlin.Comparator { o1, o2 ->\n o1.second.compareTo(o2.second)\n })\n pQueue.addAll(requests)\n\n var answer = 0\n\n while (pQueue.isNotEmpty()) {\n val (from, to) = pQueue.poll()\n if (from < cutOnLeft) continue\n cutOnLeft = max(cutOnLeft, to)\n answer++\n }\n\n println(answer)\n}\n\n// region kokokara template dayo (^o^)\n@Suppress(\"unused\", \"ClassName\", \"SpellCheckingInspection\", \"ConvertToStringTemplate\", \"MemberVisibilityCanBePrivate\")\nprivate class IO_abc103d(private val separator: String = System.lineSeparator()) {\n private val input = System.`in`\n private val buffer = ByteArray(1024)\n private var pointer = 0\n private var bufferLength = 0\n private val sb = StringBuilder()\n private fun Byte.isPrintable() = this in 33..126\n private fun Byte.isNumeric() = this in '0'.toByte()..'9'.toByte()\n private fun Byte.toNumVal() = if (this.isNumeric()) this - '0'.toByte() else error(\"$this is not numeric\")\n\n private fun hasNextByte(): Boolean {\n return if (pointer < bufferLength) true else {\n pointer = 0\n bufferLength = input.read(buffer)\n bufferLength > 0\n }\n }\n\n private fun readByte(): Byte = if (hasNextByte()) buffer[pointer++] else -1\n private fun skipUnprintable() = run { while (hasNextByte() && !buffer[pointer].isPrintable()) pointer++ }\n private fun hasNext(): Boolean = run { skipUnprintable() }.run { hasNextByte() }\n private fun hasNextOrError() = if (!hasNext()) error(\"has no next element.\") else Unit\n\n fun readString(): String {\n hasNextOrError()\n val sb = StringBuilder()\n var b = readByte()\n while (b.isPrintable()) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun readLong(): Long {\n hasNextOrError()\n var n = 0L\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n if (!b.isNumeric()) error(\"$b is not numeric.\")\n while (true) {\n when {\n b.isNumeric() -> n = n * 10 + b.toNumVal()\n b.toInt() == -1 || !b.isPrintable() -> return if (negative) -n else n\n else -> error(\"failed to parse. [n=$n, b=$b]\")\n }\n b = readByte()\n }\n }\n\n fun readInt() = readLong()\n .let { if (it in Int.MIN_VALUE..Int.MAX_VALUE) it.toInt() else error(\"$it is not in range of Int.\") }\n\n fun readDouble(): Double {\n var n = 0.0\n var div = 1.0\n var negative = false\n var b = readByte()\n if (b == '-'.toByte()) {\n negative = true\n b = readByte()\n }\n do n = n * 10 + b.toNumVal()\n while (run { b = readByte() }.run { b.isNumeric() })\n if (b == '.'.toByte()) {\n while (run { b = readByte() }.run { b.isNumeric() })\n n += b.toNumVal() / (run { div *= 10 }.run { div })\n }\n return if (negative) -n else n\n }\n\n fun readStringList(size: Int) = readList(size) { readString() }\n fun readIntList(size: Int) = readList(size) { readInt() }\n fun readLongList(size: Int) = readList(size) { readLong() }\n fun readDoubleList(size: Int) = readList(size) { readDouble() }\n fun readIntArray(size: Int) = IntArray(size) { readInt() }\n fun readLongArray(size: Int) = LongArray(size) { readLong() }\n fun readDoubleArray(size: Int) = DoubleArray(size) { readDouble() }\n inline fun readArray(size: Int, init: () -> T) = Array(size) { init() }\n inline fun readList(size: Int, init: () -> T) = List(size) { init() }\n\n fun println(): Unit = run { sb.append(separator) }\n fun print(any: Any): Unit = run { sb.append(any) }\n fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }\n\n fun exec(code: IO_abc103d.() -> Unit) = run {\n Thread(null, { code() }, \"(^o^)\", 128 * 1024 * 1024).apply { start() }.join()\n }.run { kotlin.io.print(sb) }\n\n fun readLine(): Nothing = error(\"readLine is disabled.\")\n}\n// endregion kokomade template dayo (^o^)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4493, "cpu_time_ms": 233, "memory_kb": 43800}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s544321343", "group_id": "codeNet:p03295", "input_text": "fun main(args : Array) {\n val (islandsSize, requestsSize) = readLine()!!.split(\" \").map { it.toInt() }\n val requests = (1..requestsSize).map {\n val input = readLine()!!.split(\" \").map { it.toInt() }\n Pair(input.get(0), input.get(1))\n }\n\n val sortedByB = requests.sortedBy { it.second }\n\n println(sortedByB)\n\n var removedBridgeNumber = 0\n var lastRemovedBridge = -1\n sortedByB.forEach {\n val (a, b) = it\n if (a < lastRemovedBridge) {\n //do nothing\n } else {\n lastRemovedBridge = b\n removedBridgeNumber++\n }\n }\n\n println(removedBridgeNumber)\n}", "language": "Kotlin", "metadata": {"date": 1533153670, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03295/input.txt", "sample_output_relpath": "derived/input_output/data/p03295/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03295/Kotlin/s544321343.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s544321343", "user_id": "u861095163"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args : Array) {\n val (islandsSize, requestsSize) = readLine()!!.split(\" \").map { it.toInt() }\n val requests = (1..requestsSize).map {\n val input = readLine()!!.split(\" \").map { it.toInt() }\n Pair(input.get(0), input.get(1))\n }\n\n val sortedByB = requests.sortedBy { it.second }\n\n println(sortedByB)\n\n var removedBridgeNumber = 0\n var lastRemovedBridge = -1\n sortedByB.forEach {\n val (a, b) = it\n if (a < lastRemovedBridge) {\n //do nothing\n } else {\n lastRemovedBridge = b\n removedBridgeNumber++\n }\n }\n\n println(removedBridgeNumber)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 654, "cpu_time_ms": 1307, "memory_kb": 101156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s236398389", "group_id": "codeNet:p03295", "input_text": "fun main(args: Array) {\n val M = readLine()!!.split(\" \")[1].toInt()\n val ab = (0 until M).map { readLine()!!.split(\" \").map { it.toInt() } }.sortedBy { it[1] }\n val list = mutableListOf()\n ab.forEach {\n if (list.isEmpty() || list.last() <= it[0]) list.add(it[1])\n }\n println(list.size)\n}", "language": "Kotlin", "metadata": {"date": 1532833038, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03295.html", "problem_id": "p03295", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03295/input.txt", "sample_output_relpath": "derived/input_output/data/p03295/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03295/Kotlin/s236398389.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s236398389", "user_id": "u771276989"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val M = readLine()!!.split(\" \")[1].toInt()\n val ab = (0 until M).map { readLine()!!.split(\" \").map { it.toInt() } }.sortedBy { it[1] }\n val list = mutableListOf()\n ab.forEach {\n if (list.isEmpty() || list.last() <= it[0]) list.add(it[1])\n }\n println(list.size)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 824, "memory_kb": 84036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s103113630", "group_id": "codeNet:p03302", "input_text": "fun main(args: Array) {\n var (a,b) = readLine()!!.split(\" \").map(String::toInt)\n if (a+b == 15) {\n println(\"+\")\n } else if (a*b == 15) {\n println(\"*\")\n } else {\n println(\"x\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1554025937, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03302.html", "problem_id": "p03302", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03302/input.txt", "sample_output_relpath": "derived/input_output/data/p03302/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03302/Kotlin/s103113630.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103113630", "user_id": "u506403362"}, "prompt_components": {"gold_output": "+\n", "input_to_evaluate": "fun main(args: Array) {\n var (a,b) = readLine()!!.split(\" \").map(String::toInt)\n if (a+b == 15) {\n println(\"+\")\n } else if (a*b == 15) {\n println(\"*\")\n } else {\n println(\"x\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers a and b.\nDetermine if a+b=15 or a\\times b=15 or neither holds.\n\nNote that a+b=15 and a\\times b=15 do not hold at the same time.\n\nConstraints\n\n1 \\leq a,b \\leq 15\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf a+b=15, print +;\nif a\\times b=15, print *;\nif neither holds, print x.\n\nSample Input 1\n\n4 11\n\nSample Output 1\n\n+\n\n4+11=15.\n\nSample Input 2\n\n3 5\n\nSample Output 2\n\n*\n\n3\\times 5=15.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nx\n\n1+1=2 and 1\\times 1=1, neither of which is 15.", "sample_input": "4 11\n"}, "reference_outputs": ["+\n"], "source_document_id": "p03302", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers a and b.\nDetermine if a+b=15 or a\\times b=15 or neither holds.\n\nNote that a+b=15 and a\\times b=15 do not hold at the same time.\n\nConstraints\n\n1 \\leq a,b \\leq 15\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf a+b=15, print +;\nif a\\times b=15, print *;\nif neither holds, print x.\n\nSample Input 1\n\n4 11\n\nSample Output 1\n\n+\n\n4+11=15.\n\nSample Input 2\n\n3 5\n\nSample Output 2\n\n*\n\n3\\times 5=15.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nx\n\n1+1=2 and 1\\times 1=1, neither of which is 15.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 233, "memory_kb": 37840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s711861847", "group_id": "codeNet:p03307", "input_text": "import java.io.BufferedReader\nimport java.io.PrintWriter\n\nvar out: PrintWriter = PrintWriter(System.out) // これを使って出力すると早い\n\nfun main(args: Array) {\n try {\n val n = ReadLib.readAsInt()\n\n out.println(if (n % 2 == 0) n else n * 2)\n\n } finally {\n out.flush() // 消さない\n }\n}\n\n/**\n * 読み取り\n */\nclass ReadLib {\n companion object {\n private var reader: BufferedReader = System.`in`.bufferedReader()\n\n fun reset() {\n reader = System.`in`.bufferedReader()\n }\n\n fun readAsInt(): Int {\n return Integer.parseInt(reader.readLine())\n }\n\n // Int\n fun readAsIntArray(delimiters: String = \" \"): IntArray {\n return reader\n .readLine()\n .split(delimiters)\n .map { s -> Integer.parseInt(s) }\n .toIntArray()\n }\n\n fun readNTimesAsInt(n: Int): IntArray {\n return (1..n).map { readAsInt() }.toIntArray()\n }\n\n fun readNTimesAsIntArray(n: Int): Array {\n return (1..n).map { readAsIntArray() }.toTypedArray()\n }\n\n // long\n // TODO 別の方法を考える\n fun readAsLong(): Long {\n return reader.readLine().toLong()\n }\n\n fun readAsLongArray(delimiters: String = \" \"): LongArray {\n return reader.readLine()\n .split(delimiters)\n .map { s -> s.toLong() }\n .toLongArray()\n }\n\n fun readNTimesAsLong(n: Int): LongArray {\n return (1..n).map { readAsLong() }.toLongArray()\n }\n\n fun readAsString(): String {\n return reader.readLine()\n }\n\n fun readAsStringArray(delimiters: String = \" \"): Array {\n return readAsString().split(delimiters).toTypedArray()\n }\n\n }\n}\n\n/**\n * 要素とその個数を出力\n */\nfun Array.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * 文字とその個数を出力\n */\nfun String.ofCountMap(): Map {\n return this.toCharArray().ofCountMap()\n}\n\n/**\n * 文字とその個数を出力\n */\nfun CharArray.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * Combination, nCk mod p を求める\n * https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%A9%E9%80%86%E6%95%B0\n * http://drken1215.hatenablog.com/entry/2018/06/08/210000\n * @param maxN 最大のn\n * @param mod 素数p\n */\nclass ModCombination(private val maxN: Int, private val mod: Int = 1000000007) {\n val fac: IntArray = IntArray(maxN)\n val finv: IntArray = IntArray(maxN)\n\n init {\n val inv: IntArray = IntArray(maxN)\n fac[0] = 1\n fac[1] = 1\n\n inv[0] = 1\n inv[1] = 1\n for (i in 2..maxN) {\n fac[i] = fac[i - 1] * i % mod // 累積\n // mod % i < i\n inv[i] = mod - ((inv[mod % i].toLong()) * (mod / i) % mod).toInt()\n finv[i] = finv[i - 1] * inv[i] % mod\n }\n }\n\n /**\n * nCk mod p\n */\n fun Calc(n: Int, k: Int): Int {\n if (n < k || n < 0 || k < 0) {\n return 0\n }\n\n return ((fac[n].toLong() * finv[k] % mod) * finv[n - k] % mod).toInt()\n }\n}", "language": "Kotlin", "metadata": {"date": 1570936342, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Kotlin/s711861847.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711861847", "user_id": "u368201579"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.PrintWriter\n\nvar out: PrintWriter = PrintWriter(System.out) // これを使って出力すると早い\n\nfun main(args: Array) {\n try {\n val n = ReadLib.readAsInt()\n\n out.println(if (n % 2 == 0) n else n * 2)\n\n } finally {\n out.flush() // 消さない\n }\n}\n\n/**\n * 読み取り\n */\nclass ReadLib {\n companion object {\n private var reader: BufferedReader = System.`in`.bufferedReader()\n\n fun reset() {\n reader = System.`in`.bufferedReader()\n }\n\n fun readAsInt(): Int {\n return Integer.parseInt(reader.readLine())\n }\n\n // Int\n fun readAsIntArray(delimiters: String = \" \"): IntArray {\n return reader\n .readLine()\n .split(delimiters)\n .map { s -> Integer.parseInt(s) }\n .toIntArray()\n }\n\n fun readNTimesAsInt(n: Int): IntArray {\n return (1..n).map { readAsInt() }.toIntArray()\n }\n\n fun readNTimesAsIntArray(n: Int): Array {\n return (1..n).map { readAsIntArray() }.toTypedArray()\n }\n\n // long\n // TODO 別の方法を考える\n fun readAsLong(): Long {\n return reader.readLine().toLong()\n }\n\n fun readAsLongArray(delimiters: String = \" \"): LongArray {\n return reader.readLine()\n .split(delimiters)\n .map { s -> s.toLong() }\n .toLongArray()\n }\n\n fun readNTimesAsLong(n: Int): LongArray {\n return (1..n).map { readAsLong() }.toLongArray()\n }\n\n fun readAsString(): String {\n return reader.readLine()\n }\n\n fun readAsStringArray(delimiters: String = \" \"): Array {\n return readAsString().split(delimiters).toTypedArray()\n }\n\n }\n}\n\n/**\n * 要素とその個数を出力\n */\nfun Array.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * 文字とその個数を出力\n */\nfun String.ofCountMap(): Map {\n return this.toCharArray().ofCountMap()\n}\n\n/**\n * 文字とその個数を出力\n */\nfun CharArray.ofCountMap(): Map {\n return this.groupBy { it }.mapValues { it.value.count() }\n}\n\n/**\n * Combination, nCk mod p を求める\n * https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%A9%E9%80%86%E6%95%B0\n * http://drken1215.hatenablog.com/entry/2018/06/08/210000\n * @param maxN 最大のn\n * @param mod 素数p\n */\nclass ModCombination(private val maxN: Int, private val mod: Int = 1000000007) {\n val fac: IntArray = IntArray(maxN)\n val finv: IntArray = IntArray(maxN)\n\n init {\n val inv: IntArray = IntArray(maxN)\n fac[0] = 1\n fac[1] = 1\n\n inv[0] = 1\n inv[1] = 1\n for (i in 2..maxN) {\n fac[i] = fac[i - 1] * i % mod // 累積\n // mod % i < i\n inv[i] = mod - ((inv[mod % i].toLong()) * (mod / i) % mod).toInt()\n finv[i] = finv[i - 1] * inv[i] % mod\n }\n }\n\n /**\n * nCk mod p\n */\n fun Calc(n: Int, k: Int): Int {\n if (n < k || n < 0 || k < 0) {\n return 0\n }\n\n return ((fac[n].toLong() * finv[k] % mod) * finv[n - k] % mod).toInt()\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3361, "cpu_time_ms": 161, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s558708146", "group_id": "codeNet:p03307", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n if (n % 2L == 0L) {\n println(n)\n } else {\n println(n * 2L)\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1530492606, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Kotlin/s558708146.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558708146", "user_id": "u099066216"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toLong()\n if (n % 2L == 0L) {\n println(n)\n } else {\n println(n * 2L)\n }\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 155, "cpu_time_ms": 247, "memory_kb": 29816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s432548371", "group_id": "codeNet:p03308", "input_text": "fun main(arr: Array) {\n val n = readLine()!!.toInt()\n val num = readLine()!!.split(\" \").map { it.toInt() }\n val ans = num.indices.map { idx-> (idx until n).map { Math.abs(num[idx] - num[it]) }.max()!! }.max()!!\n println(ans)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1600023584, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Kotlin/s432548371.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432548371", "user_id": "u269969976"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(arr: Array) {\n val n = readLine()!!.toInt()\n val num = readLine()!!.split(\" \").map { it.toInt() }\n val ans = num.indices.map { idx-> (idx until n).map { Math.abs(num[idx] - num[it]) }.max()!! }.max()!!\n println(ans)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 248, "cpu_time_ms": 144, "memory_kb": 38592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s012167648", "group_id": "codeNet:p03309", "input_text": "fun main(args: Array) {\n abc102c()\n}\n\nfun abc102c() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(\" \").map { it.toInt() }\n .mapIndexed { index, i -> i - (index + 1) }\n .sorted()\n\n val mid = aList[aList.size / 2 - 1]\n\n val answer = aList.map { Math.abs(it - mid) }.sum()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1569286884, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Kotlin/s012167648.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s012167648", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n abc102c()\n}\n\nfun abc102c() {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(\" \").map { it.toInt() }\n .mapIndexed { index, i -> i - (index + 1) }\n .sorted()\n\n val mid = aList[aList.size / 2 - 1]\n\n val answer = aList.map { Math.abs(it - mid) }.sum()\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 1012, "memory_kb": 80700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s454046385", "group_id": "codeNet:p03309", "input_text": "fun main(args : Array) {\n readLine()\n val nums = readLine()!!.split(\" \").map { it.toInt() }\n val nums_reduced = nums.mapIndexed { index, i -> i - index }\n\n var top = nums_reduced.max()!!\n var bottom = nums_reduced.min()!!\n var mid = (top + bottom) / 2\n while (true){\n if (betterToInclement(nums_reduced, mid)) {\n bottom = mid\n mid = (top + bottom) / 2\n if (mid == bottom) {\n mid ++\n }\n } else if (betterToDeclement(nums_reduced, mid)) {\n top = mid\n mid = (top + bottom) / 2\n if (mid == top) {\n mid --\n }\n } else {\n break\n }\n }\n\n nums_reduced.sumBy { abs(it - mid) }.let { println(it) }\n\n}\n\nfun abs(a: Int) = if (a > 0) a else -a\n\nfun betterToInclement(array: Iterable, b: Int) = array.sumBy { if (it > b) 1 else -1 } > 0\nfun betterToDeclement(array: Iterable, b: Int) = array.sumBy { if (it < b) 1 else -1 } > 0\n", "language": "Kotlin", "metadata": {"date": 1564618281, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Kotlin/s454046385.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s454046385", "user_id": "u714769076"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n readLine()\n val nums = readLine()!!.split(\" \").map { it.toInt() }\n val nums_reduced = nums.mapIndexed { index, i -> i - index }\n\n var top = nums_reduced.max()!!\n var bottom = nums_reduced.min()!!\n var mid = (top + bottom) / 2\n while (true){\n if (betterToInclement(nums_reduced, mid)) {\n bottom = mid\n mid = (top + bottom) / 2\n if (mid == bottom) {\n mid ++\n }\n } else if (betterToDeclement(nums_reduced, mid)) {\n top = mid\n mid = (top + bottom) / 2\n if (mid == top) {\n mid --\n }\n } else {\n break\n }\n }\n\n nums_reduced.sumBy { abs(it - mid) }.let { println(it) }\n\n}\n\nfun abs(a: Int) = if (a > 0) a else -a\n\nfun betterToInclement(array: Iterable, b: Int) = array.sumBy { if (it > b) 1 else -1 } > 0\nfun betterToDeclement(array: Iterable, b: Int) = array.sumBy { if (it < b) 1 else -1 } > 0\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1014, "cpu_time_ms": 663, "memory_kb": 80808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s923476608", "group_id": "codeNet:p03309", "input_text": "fun main(args : Array) {\n val N = readLine()!!.toInt()\n var A = readLine()!!.split(\" \").map { it.toInt() }\n A= (1..N).map {\n val index = it - 1\n A.get(index) - it\n }.sorted()\n\n var median1 = A.get(N / 2)\n var median2 = A.get(N/2 - 1)\n\n val answer = Math.min(A.map { Math.abs(it - median1)}.sum(), A.map { Math.abs(it - median2)}.sum())\n\n println(answer)\n}", "language": "Kotlin", "metadata": {"date": 1533485827, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Kotlin/s923476608.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s923476608", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args : Array) {\n val N = readLine()!!.toInt()\n var A = readLine()!!.split(\" \").map { it.toInt() }\n A= (1..N).map {\n val index = it - 1\n A.get(index) - it\n }.sorted()\n\n var median1 = A.get(N / 2)\n var median2 = A.get(N/2 - 1)\n\n val answer = Math.min(A.map { Math.abs(it - median1)}.sum(), A.map { Math.abs(it - median2)}.sum())\n\n println(answer)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 401, "cpu_time_ms": 1167, "memory_kb": 83364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s886680975", "group_id": "codeNet:p03309", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(' ').mapIndexed { i, s -> s.toLong() - (i + 1) }.sorted()\n println(f(xs, xs[n / 2]))\n}\n\nprivate fun f(xs: List, b: Long): Long {\n return xs.map { Math.abs(it - b) }.sum()\n}", "language": "Kotlin", "metadata": {"date": 1530674908, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Kotlin/s886680975.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s886680975", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val xs = readLine()!!.split(' ').mapIndexed { i, s -> s.toLong() - (i + 1) }.sorted()\n println(f(xs, xs[n / 2]))\n}\n\nprivate fun f(xs: List, b: Long): Long {\n return xs.map { Math.abs(it - b) }.sum()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 970, "memory_kb": 78936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s507866190", "group_id": "codeNet:p03309", "input_text": "fun main(args: Array) {\n readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n var b = 0\n var sadness = calcSadness(a, b)\n\n while (true) {\n val s = calcSadness(a, b + 1)\n\n if (sadness >= s) {\n sadness = s\n b++\n continue\n }\n\n break\n }\n\n while (true) {\n val s = calcSadness(a, b - 1)\n\n if (sadness >= s) {\n sadness = s\n b--\n continue\n }\n\n break\n }\n\n println(sadness)\n}\n\nfun calcSadness(values: List, b: Int): Int {\n return values.mapIndexed { i, value -> Math.abs(value - (b + i + 1)) }.sum()\n}", "language": "Kotlin", "metadata": {"date": 1530493162, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03309/input.txt", "sample_output_relpath": "derived/input_output/data/p03309/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03309/Kotlin/s507866190.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s507866190", "user_id": "u863309603"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()!!.toInt()\n val a = readLine()!!.split(' ').map { it.toInt() }\n\n var b = 0\n var sadness = calcSadness(a, b)\n\n while (true) {\n val s = calcSadness(a, b + 1)\n\n if (sadness >= s) {\n sadness = s\n b++\n continue\n }\n\n break\n }\n\n while (true) {\n val s = calcSadness(a, b - 1)\n\n if (sadness >= s) {\n sadness = s\n b--\n continue\n }\n\n break\n }\n\n println(sadness)\n}\n\nfun calcSadness(values: List, b: Int): Int {\n return values.mapIndexed { i, value -> Math.abs(value - (b + i + 1)) }.sum()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 678, "cpu_time_ms": 2111, "memory_kb": 152348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s642741448", "group_id": "codeNet:p03310", "input_text": "package atcoder.abc102\n\nfun main(args : Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }.toMutableList()\n prefixSum(A)\n\n var min = Long.MAX_VALUE\n\n fun findPositionCandidates(a: List) : List {\n val totalSum = a.last()\n val candidate = lowerBound(a, totalSum / 2)\n\n return listOf(candidate - 1, candidate, candidate + 1).filter { 0 <= it && it <= a.size - 2 }\n }\n\n // O(NlogN)\n for (center in 2..N-2) {\n val L = A.subList(0, center)\n val R = A.subList(center, N).map{ it - L.last() }\n\n val partitionPositionForL = findPositionCandidates(L)\n val partitionPositionForR = findPositionCandidates(R)\n\n val (diffPQ, sumP, sumQ) = partitionPositionForL.map {\n val sumP = L.get(it)\n val sumQ = L.last() - L.get(it)\n Triple(Math.abs(sumP - sumQ), sumP, sumQ)\n }.minBy { it.first }!!\n\n val (diffRS, sumR, sumS) = partitionPositionForR.map {\n val sumR = R.get(it)\n val sumS = R.last() - R.get(it)\n Triple(Math.abs(sumR - sumS), sumR, sumS)\n }.minBy { it.first }!!\n\n\n val list = listOf(sumP, sumQ, sumR, sumS).sorted()\n val result = list.last() - list.first()\n min = Math.min(min, result)\n }\n\n println(min)\n}\n\nfun prefixSum(A: MutableList) {\n for(i in 1..(A.size - 1)) {\n A.set(i, A.get(i) + A.get(i - 1))\n }\n}\n\n\nfun lowerBound(sortedList: List, key: Long) : Int {\n var ok = sortedList.size\n var ng = -1\n\n fun isOk(mid: Int) : Boolean {\n return sortedList.get(mid) >= key\n }\n\n while (Math.abs(ok-ng) > 1) {\n val mid = (ok + ng) / 2\n\n if (isOk(mid)) {\n ok = mid\n } else {\n ng = mid\n }\n }\n\n return ok\n}\n", "language": "Kotlin", "metadata": {"date": 1533556202, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03310.html", "problem_id": "p03310", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03310/input.txt", "sample_output_relpath": "derived/input_output/data/p03310/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03310/Kotlin/s642741448.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s642741448", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "package atcoder.abc102\n\nfun main(args : Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }.toMutableList()\n prefixSum(A)\n\n var min = Long.MAX_VALUE\n\n fun findPositionCandidates(a: List) : List {\n val totalSum = a.last()\n val candidate = lowerBound(a, totalSum / 2)\n\n return listOf(candidate - 1, candidate, candidate + 1).filter { 0 <= it && it <= a.size - 2 }\n }\n\n // O(NlogN)\n for (center in 2..N-2) {\n val L = A.subList(0, center)\n val R = A.subList(center, N).map{ it - L.last() }\n\n val partitionPositionForL = findPositionCandidates(L)\n val partitionPositionForR = findPositionCandidates(R)\n\n val (diffPQ, sumP, sumQ) = partitionPositionForL.map {\n val sumP = L.get(it)\n val sumQ = L.last() - L.get(it)\n Triple(Math.abs(sumP - sumQ), sumP, sumQ)\n }.minBy { it.first }!!\n\n val (diffRS, sumR, sumS) = partitionPositionForR.map {\n val sumR = R.get(it)\n val sumS = R.last() - R.get(it)\n Triple(Math.abs(sumR - sumS), sumR, sumS)\n }.minBy { it.first }!!\n\n\n val list = listOf(sumP, sumQ, sumR, sumS).sorted()\n val result = list.last() - list.first()\n min = Math.min(min, result)\n }\n\n println(min)\n}\n\nfun prefixSum(A: MutableList) {\n for(i in 1..(A.size - 1)) {\n A.set(i, A.get(i) + A.get(i - 1))\n }\n}\n\n\nfun lowerBound(sortedList: List, key: Long) : Int {\n var ok = sortedList.size\n var ng = -1\n\n fun isOk(mid: Int) : Boolean {\n return sortedList.get(mid) >= key\n }\n\n while (Math.abs(ok-ng) > 1) {\n val mid = (ok + ng) / 2\n\n if (isOk(mid)) {\n ok = mid\n } else {\n ng = mid\n }\n }\n\n return ok\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "sample_input": "5\n3 2 4 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03310", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1859, "cpu_time_ms": 155, "memory_kb": 31392}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s363011638", "group_id": "codeNet:p03310", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }\n\n val a = LongArray(N)\n var ps: Long = 0\n A.forEachIndexed { index, l ->\n ps += l\n a[index] = ps\n }\n\n var min = Long.MAX_VALUE\n for (i in 0 until N - 3) for (j in i + 1 until N - 2) for (k in j + 1 until N - 1) {\n longArrayOf(a[i], a[j] - a[i], a[k] - a[j], a.last() - a[k]).sorted().apply { min = Math.min(min, last() - first()) }\n }\n println(min)\n}", "language": "Kotlin", "metadata": {"date": 1532874255, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03310.html", "problem_id": "p03310", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03310/input.txt", "sample_output_relpath": "derived/input_output/data/p03310/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03310/Kotlin/s363011638.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s363011638", "user_id": "u771276989"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toLong() }\n\n val a = LongArray(N)\n var ps: Long = 0\n A.forEachIndexed { index, l ->\n ps += l\n a[index] = ps\n }\n\n var min = Long.MAX_VALUE\n for (i in 0 until N - 3) for (j in i + 1 until N - 2) for (k in j + 1 until N - 1) {\n longArrayOf(a[i], a[j] - a[i], a[k] - a[j], a.last() - a[k]).sorted().apply { min = Math.min(min, last() - first()) }\n }\n println(min)\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "sample_input": "5\n3 2 4 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03310", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 516, "cpu_time_ms": 2111, "memory_kb": 144568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s108435553", "group_id": "codeNet:p03316", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = n.toString().map { it - '0' }.sum()\n println(if (n % s == 0) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1559615308, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03316/input.txt", "sample_output_relpath": "derived/input_output/data/p03316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03316/Kotlin/s108435553.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s108435553", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val s = n.toString().map { it - '0' }.sum()\n println(if (n % s == 0) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03316", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 160, "cpu_time_ms": 208, "memory_kb": 33904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s090225179", "group_id": "codeNet:p03316", "input_text": "import java.util.Scanner\n \nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val string = scanner.next()\n scanner.close()\n var sum = 0\n for (char in string.toCharArray()) {\n sum += char.toString().toInt()\n }\n print(if(string.toInt() % sum == 0) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1529803500, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03316/input.txt", "sample_output_relpath": "derived/input_output/data/p03316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03316/Kotlin/s090225179.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s090225179", "user_id": "u992174257"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n \nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val string = scanner.next()\n scanner.close()\n var sum = 0\n for (char in string.toCharArray()) {\n sum += char.toString().toInt()\n }\n print(if(string.toInt() % sum == 0) \"Yes\" else \"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03316", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 292, "cpu_time_ms": 181, "memory_kb": 29352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s248526062", "group_id": "codeNet:p03317", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n println(problem101c(n, k, a))\n}\n\nfun problem101c(n: Int, k: Int, a: List): Int {\n if (n == k) return 1\n return ((n - 1) / (k - 1) + if ((n - 1) % (k - 1) != 0) 1 else 0)\n}", "language": "Kotlin", "metadata": {"date": 1583901131, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Kotlin/s248526062.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s248526062", "user_id": "u073232808"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (0 until n).map { sc.next().toInt() }\n println(problem101c(n, k, a))\n}\n\nfun problem101c(n: Int, k: Int, a: List): Int {\n if (n == k) return 1\n return ((n - 1) / (k - 1) + if ((n - 1) % (k - 1) != 0) 1 else 0)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 372, "cpu_time_ms": 639, "memory_kb": 49424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s819191422", "group_id": "codeNet:p03317", "input_text": "fun readInts() = readLine()!!.split(' ').map(String::toInt)\n\nfun main(args: Array) {\n val (n, k) = readInts()\n readLine()\n var x = 1 + (n - k) / (k - 1)\n if ((n - k) % (k - 1) != 0) x++\n println(x)\n}\n", "language": "Kotlin", "metadata": {"date": 1564713633, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Kotlin/s819191422.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819191422", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun readInts() = readLine()!!.split(' ').map(String::toInt)\n\nfun main(args: Array) {\n val (n, k) = readInts()\n readLine()\n var x = 1 + (n - k) / (k - 1)\n if ((n - k) % (k - 1) != 0) x++\n println(x)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 279, "memory_kb": 41376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s421720969", "group_id": "codeNet:p03317", "input_text": "fun main(args: Array) {\n val (n,k)=readLine()!!.split(\" \").map{it.toInt()}\n readLine()\n println( 1+(n-2)/(k-1))\n}", "language": "Kotlin", "metadata": {"date": 1541442551, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Kotlin/s421720969.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s421720969", "user_id": "u914096045"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,k)=readLine()!!.split(\" \").map{it.toInt()}\n readLine()\n println( 1+(n-2)/(k-1))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 285, "memory_kb": 41464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s387759155", "group_id": "codeNet:p03317", "input_text": "/**\n * Created by karayuu on 2018/06/23\n */\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n print(Math.ceil(n.toDouble() / k.toDouble()).toInt() + 1)\n}\n", "language": "Kotlin", "metadata": {"date": 1529807604, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Kotlin/s387759155.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s387759155", "user_id": "u598902504"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/**\n * Created by karayuu on 2018/06/23\n */\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n print(Math.ceil(n.toDouble() / k.toDouble()).toInt() + 1)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 200, "cpu_time_ms": 238, "memory_kb": 37928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s210495636", "group_id": "codeNet:p03317", "input_text": "fun main(args: Array){\n val (N, K) = readLine()!!.split(' ').map(String::toInt)\n val A: Array = readLine()!!.split(' ').map(String::toInt).toTypedArray()\n var size = A.size\n var counter = 0\n\n while (size > 0){\n size -= K - 1\n if (counter == 0){\n size -= 1\n }\n counter ++\n if (size <= 0) println(counter)\n }\n}", "language": "Kotlin", "metadata": {"date": 1529804728, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Kotlin/s210495636.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s210495636", "user_id": "u491523420"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array){\n val (N, K) = readLine()!!.split(' ').map(String::toInt)\n val A: Array = readLine()!!.split(' ').map(String::toInt).toTypedArray()\n var size = A.size\n var counter = 0\n\n while (size > 0){\n size -= K - 1\n if (counter == 0){\n size -= 1\n }\n counter ++\n if (size <= 0) println(counter)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 496, "memory_kb": 47784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s142063713", "group_id": "codeNet:p03318", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val k = sc.nextInt()\n\n val l = ArrayList()\n l.add(1L)\n // 桁和\n var sum = 2\n\n fun dSum(l: Long): Long = if (l < 10) l else dSum(l / 10) + l % 10\n\n fun min(s: Int): Long {\n val d = s / 9\n val m = s % 9\n var t = m.toLong()\n for (i in 0 until d) {\n t *= 10\n t += 9\n }\n return t\n }\n\n fun next(sum: Int): ArrayList {\n val t = min(sum)\n val s = if (sum % 9 == 0) \"0${t}\" else t.toString()\n val ss = s.toCharArray()\n val res = ArrayList()\n res.add(t)\n for (i in 0 until ss.size - 1) {\n ss[i]++\n ss[i + 1]--\n res.add(String(ss).toLong())\n }\n return res\n }\n\n while (l.size < k) {\n val next = min(sum + 1)\n // 桁和+1 より小さい 桁和sumの値を小さい順に列挙\n val nn = next(sum)\n for (i in 0 until nn.size) {\n if(l.size >= k) break\n if(nn[i] * (sum+1) > next * sum) break\n l.add(nn[i])\n }\n sum++\n\n }\n println(l.joinToString(\"\\n\"))\n }\n\n\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1583902022, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03318/input.txt", "sample_output_relpath": "derived/input_output/data/p03318/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03318/Kotlin/s142063713.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s142063713", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val k = sc.nextInt()\n\n val l = ArrayList()\n l.add(1L)\n // 桁和\n var sum = 2\n\n fun dSum(l: Long): Long = if (l < 10) l else dSum(l / 10) + l % 10\n\n fun min(s: Int): Long {\n val d = s / 9\n val m = s % 9\n var t = m.toLong()\n for (i in 0 until d) {\n t *= 10\n t += 9\n }\n return t\n }\n\n fun next(sum: Int): ArrayList {\n val t = min(sum)\n val s = if (sum % 9 == 0) \"0${t}\" else t.toString()\n val ss = s.toCharArray()\n val res = ArrayList()\n res.add(t)\n for (i in 0 until ss.size - 1) {\n ss[i]++\n ss[i + 1]--\n res.add(String(ss).toLong())\n }\n return res\n }\n\n while (l.size < k) {\n val next = min(sum + 1)\n // 桁和+1 より小さい 桁和sumの値を小さい順に列挙\n val nn = next(sum)\n for (i in 0 until nn.size) {\n if(l.size >= k) break\n if(nn[i] * (sum+1) > next * sum) break\n l.add(nn[i])\n }\n sum++\n\n }\n println(l.joinToString(\"\\n\"))\n }\n\n\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "sample_input": "10\n"}, "reference_outputs": ["1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n"], "source_document_id": "p03318", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4053, "cpu_time_ms": 204, "memory_kb": 29856}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s244915844", "group_id": "codeNet:p03318", "input_text": "fun main(args: Array) {\n val k = readLine()!!.toInt()\n if (k<=9) {\n for(i in 1 until k+1) println(i)\n return\n }\n\n for(i in 1 until 10) println(i)\n\n var n = k - 9\n var snk = 19\n while(n-- > 0) {\n println(snk)\n snk += 10\n }\n}", "language": "Kotlin", "metadata": {"date": 1529803389, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03318/input.txt", "sample_output_relpath": "derived/input_output/data/p03318/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03318/Kotlin/s244915844.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s244915844", "user_id": "u185034753"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "fun main(args: Array) {\n val k = readLine()!!.toInt()\n if (k<=9) {\n for(i in 1 until k+1) println(i)\n return\n }\n\n for(i in 1 until 10) println(i)\n\n var n = k - 9\n var snk = 19\n while(n-- > 0) {\n println(snk)\n snk += 10\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "sample_input": "10\n"}, "reference_outputs": ["1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n"], "source_document_id": "p03318", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 283, "cpu_time_ms": 224, "memory_kb": 33648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s087287397", "group_id": "codeNet:p03319", "input_text": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main(args: Array) {\n val (n, k) = intList()\n val a = intList()\n val nn = n - 1\n val kk = k - 1\n val c = nn / kk + if (nn % kk != 0) {\n 1\n } else {\n 0\n }\n println(c.toString())\n}\n", "language": "Kotlin", "metadata": {"date": 1591498682, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03319/input.txt", "sample_output_relpath": "derived/input_output/data/p03319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03319/Kotlin/s087287397.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087287397", "user_id": "u979429407"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main(args: Array) {\n val (n, k) = intList()\n val a = intList()\n val nn = n - 1\n val kk = k - 1\n val c = nn / kk + if (nn % kk != 0) {\n 1\n } else {\n 0\n }\n println(c.toString())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03319", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 297, "cpu_time_ms": 469, "memory_kb": 49640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s527643279", "group_id": "codeNet:p03325", "input_text": "fun main() {\n\n val n = readLine()!!.toInt()\n\n val list = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n\n var count = 0\n\n for (i in 0 until n) {\n while (list[i]%2==0){\n list[i] = list[i]/2\n count++\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1597245358, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03325/input.txt", "sample_output_relpath": "derived/input_output/data/p03325/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03325/Kotlin/s527643279.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s527643279", "user_id": "u592533051"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main() {\n\n val n = readLine()!!.toInt()\n\n val list = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n\n var count = 0\n\n for (i in 0 until n) {\n while (list[i]%2==0){\n list[i] = list[i]/2\n count++\n }\n }\n println(count)\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 240, "memory_kb": 43124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s552604041", "group_id": "codeNet:p03325", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val inputs = readLine()!!.split(\" \").map { it.toInt() }\n\n var cnt = 0\n for (v in inputs) {\n var tmp = v\n\n while (tmp % 2 == 0) {\n tmp /= 2\n cnt += 1\n }\n }\n\n println(cnt)\n}", "language": "Kotlin", "metadata": {"date": 1564851439, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03325/input.txt", "sample_output_relpath": "derived/input_output/data/p03325/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03325/Kotlin/s552604041.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552604041", "user_id": "u889750959"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val inputs = readLine()!!.split(\" \").map { it.toInt() }\n\n var cnt = 0\n for (v in inputs) {\n var tmp = v\n\n while (tmp % 2 == 0) {\n tmp /= 2\n cnt += 1\n }\n }\n\n println(cnt)\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 437, "memory_kb": 42168}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s512334372", "group_id": "codeNet:p03326", "input_text": "fun main(args: Array) {\n val (N, M) = listOfInt()\n val X = LongArray(N); val Y = LongArray(N); val Z = LongArray(N)\n repeat(N) { n ->\n val (x, y, z) = listOfLong()\n X[n] = x; Y[n] = y; Z[n] = z\n }\n var ans = 0L\n for (b in 0 until 8) {\n val A = LongArray(N)\n for (n in 0 until N) {\n A[n] += (if ((b and 1) == 0) X[n] else -X[n])\n A[n] += (if ((b and 2) == 0) Y[n] else -Y[n])\n A[n] += (if ((b and 4) == 0) Z[n] else -Z[n])\n }\n A.sortDescending()\n var w = A.slice(0 until M).sum()\n if (ans < w) ans = w\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n", "language": "Kotlin", "metadata": {"date": 1584363991, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03326.html", "problem_id": "p03326", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03326/input.txt", "sample_output_relpath": "derived/input_output/data/p03326/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03326/Kotlin/s512334372.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512334372", "user_id": "u043150661"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M) = listOfInt()\n val X = LongArray(N); val Y = LongArray(N); val Z = LongArray(N)\n repeat(N) { n ->\n val (x, y, z) = listOfLong()\n X[n] = x; Y[n] = y; Z[n] = z\n }\n var ans = 0L\n for (b in 0 until 8) {\n val A = LongArray(N)\n for (n in 0 until N) {\n A[n] += (if ((b and 1) == 0) X[n] else -X[n])\n A[n] += (if ((b and 2) == 0) Y[n] else -Y[n])\n A[n] += (if ((b and 4) == 0) Z[n] else -Z[n])\n }\n A.sortDescending()\n var w = A.slice(0 until M).sum()\n if (ans < w) ans = w\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1 z_1\nx_2 y_2 z_2\n: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "sample_input": "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n"}, "reference_outputs": ["56\n"], "source_document_id": "p03326", "source_text": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1 z_1\nx_2 y_2 z_2\n: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 839, "cpu_time_ms": 344, "memory_kb": 42532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s753741985", "group_id": "codeNet:p03328", "input_text": "fun main(args: Array) {\n val (A, B) = readLine()!!.split(\" \").map(String::toInt)\n\n val diff = B - A\n\n for (i in 2..999) {\n val cur = (1..i).sum()\n val pre = (1..i - 1).sum()\n if (cur - pre == diff) {\n println(cur - B)\n return\n }\n }\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1566933595, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03328.html", "problem_id": "p03328", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03328/input.txt", "sample_output_relpath": "derived/input_output/data/p03328/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03328/Kotlin/s753741985.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753741985", "user_id": "u085288971"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B) = readLine()!!.split(\" \").map(String::toInt)\n\n val diff = B - A\n\n for (i in 2..999) {\n val cur = (1..i).sum()\n val pre = (1..i - 1).sum()\n if (cur - pre == diff) {\n println(cur - B)\n return\n }\n }\n}\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "sample_input": "8 13\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03328", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 254, "memory_kb": 38064}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s746366761", "group_id": "codeNet:p03329", "input_text": "import java.util.concurrent.LinkedBlockingDeque\nimport kotlin.math.min\n\nfun main() {\n val n = readLine()?.toInt() ?: return\n val r = n\n var c = Int.MAX_VALUE\n\n fun sub(v: Int): Pair {\n var six = 6\n if (six > v) {\n six = -1\n } else {\n while (true) {\n if (six == v) {\n break\n }\n val newSix = six * 6\n if (newSix > v) {\n break\n }\n six = newSix\n }\n }\n var nine = 9\n if (nine > v) {\n nine = -1\n } else {\n while (true) {\n if (nine == v) {\n break\n }\n val newNine = nine * 9\n if (newNine > v) {\n break\n }\n nine = newNine\n }\n }\n return Pair(six, nine)\n }\n\n val f = sub(r)\n val queue = LinkedBlockingDeque>()\n if (f.first != -1) {\n queue.offer(listOf(f.first))\n } else {\n c = min(c, r)\n }\n if (f.second != -1) {\n queue.offer(listOf(f.second))\n } else {\n c = min(c, r)\n }\n\n while (queue.isNotEmpty()) {\n val q = queue.poll()\n val s = q.sum()\n val next = sub(r - s)\n if (next.first == -1) {\n c = min(\n c, q.size + if (s == r) 0 else {\n r - s\n }\n )\n } else {\n queue.offer(q + listOf(next.first))\n }\n if (next.second == -1) {\n c = min(\n c, q.size + if (s == r) 0 else {\n r - s\n }\n )\n } else {\n queue.offer(q + listOf(next.second))\n }\n }\n println(c.toString())\n}", "language": "Kotlin", "metadata": {"date": 1598127540, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Kotlin/s746366761.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s746366761", "user_id": "u979429407"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.concurrent.LinkedBlockingDeque\nimport kotlin.math.min\n\nfun main() {\n val n = readLine()?.toInt() ?: return\n val r = n\n var c = Int.MAX_VALUE\n\n fun sub(v: Int): Pair {\n var six = 6\n if (six > v) {\n six = -1\n } else {\n while (true) {\n if (six == v) {\n break\n }\n val newSix = six * 6\n if (newSix > v) {\n break\n }\n six = newSix\n }\n }\n var nine = 9\n if (nine > v) {\n nine = -1\n } else {\n while (true) {\n if (nine == v) {\n break\n }\n val newNine = nine * 9\n if (newNine > v) {\n break\n }\n nine = newNine\n }\n }\n return Pair(six, nine)\n }\n\n val f = sub(r)\n val queue = LinkedBlockingDeque>()\n if (f.first != -1) {\n queue.offer(listOf(f.first))\n } else {\n c = min(c, r)\n }\n if (f.second != -1) {\n queue.offer(listOf(f.second))\n } else {\n c = min(c, r)\n }\n\n while (queue.isNotEmpty()) {\n val q = queue.poll()\n val s = q.sum()\n val next = sub(r - s)\n if (next.first == -1) {\n c = min(\n c, q.size + if (s == r) 0 else {\n r - s\n }\n )\n } else {\n queue.offer(q + listOf(next.first))\n }\n if (next.second == -1) {\n c = min(\n c, q.size + if (s == r) 0 else {\n r - s\n }\n )\n } else {\n queue.offer(q + listOf(next.second))\n }\n }\n println(c.toString())\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1855, "cpu_time_ms": 1875, "memory_kb": 189452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s603907108", "group_id": "codeNet:p03329", "input_text": "package point300\n\n//参考資料\n//https://qiita.com/drken/items/ace3142967c4f01d42e9\n\nval memo = mutableMapOf()\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n println(recur(n))\n}\n\nfun recur(n: Int): Int {\n if (n == 0) return 0\n if (memo.containsKey(n)) return memo[n]!!\n var res = n\n if (n < 6) {\n res = Math.min(res, recur(n - 1) + 1)\n }\n\n var pow6 = 6\n while (pow6 <= n) {\n res = Math.min(res, recur(n - pow6) + 1)\n pow6 *= 6\n }\n\n var pow9 = 9\n while (pow9 <= n) {\n res = Math.min(res, recur(n - pow9) + 1)\n pow9 *= 9\n }\n\n memo[n] = res\n return res\n}\n\n", "language": "Kotlin", "metadata": {"date": 1529094441, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Kotlin/s603907108.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s603907108", "user_id": "u099066216"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "package point300\n\n//参考資料\n//https://qiita.com/drken/items/ace3142967c4f01d42e9\n\nval memo = mutableMapOf()\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n println(recur(n))\n}\n\nfun recur(n: Int): Int {\n if (n == 0) return 0\n if (memo.containsKey(n)) return memo[n]!!\n var res = n\n if (n < 6) {\n res = Math.min(res, recur(n - 1) + 1)\n }\n\n var pow6 = 6\n while (pow6 <= n) {\n res = Math.min(res, recur(n - pow6) + 1)\n pow6 *= 6\n }\n\n var pow9 = 9\n while (pow9 <= n) {\n res = Math.min(res, recur(n - pow9) + 1)\n pow9 *= 9\n }\n\n memo[n] = res\n return res\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 661, "cpu_time_ms": 159, "memory_kb": 31524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s144556896", "group_id": "codeNet:p03329", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var r = n\n for (i in 0..n) {\n var count = 0\n\n var t = i\n while (t > 0) {\n count += t % 6\n t /= 6\n }\n\n t = n - i\n while (t > 0) {\n count += t % 9\n t /= 9\n }\n\n r = Math.min(r, count)\n }\n println(r)\n}", "language": "Kotlin", "metadata": {"date": 1528686470, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Kotlin/s144556896.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s144556896", "user_id": "u863309603"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n var r = n\n for (i in 0..n) {\n var count = 0\n\n var t = i\n while (t > 0) {\n count += t % 6\n t /= 6\n }\n\n t = n - i\n while (t > 0) {\n count += t % 9\n t /= 9\n }\n\n r = Math.min(r, count)\n }\n println(r)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 210, "memory_kb": 31676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s196523602", "group_id": "codeNet:p03332", "input_text": "fun main(args: Array) {\n val divisor = 998244353\n\n val inputs = readLine()!!.split(\" \")\n val n = inputs[0].toInt()\n val a = inputs[1].toInt()\n val b = inputs[2].toInt()\n val k = inputs[3].toInt()\n\n val counts = mutableListOf>()\n for (green in 0..n) {\n for (red in 0..(n - green)) {\n for (blue in 0..(n - green - red)) {\n val point = a * red + (a + b) * green + b * blue\n if (point == k) {\n counts.add(Triple(red, green, blue))\n } else if (point > k) {\n break\n }\n }\n }\n }\n\n val sum = counts.map {\n val red = it.first\n val green = it.second\n val blue = it.third\n c(n, red) * c(n - red, green) * c(n - red - green, blue)\n }.sum()\n\n println(sum % divisor)\n}\n\nfun c(x: Int, y: Int): Int {\n if (y == 0) {\n return 1\n }\n// println(\"x=$x, y=$y, answer=${((x - y + 1)..x).reduce(Int::times) / (1..y).reduce(Int::times)}\")\n return ((x - y + 1)..x).reduce(Int::times) / (1..y).reduce(Int::times)\n}", "language": "Kotlin", "metadata": {"date": 1530301796, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03332.html", "problem_id": "p03332", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03332/input.txt", "sample_output_relpath": "derived/input_output/data/p03332/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03332/Kotlin/s196523602.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s196523602", "user_id": "u456722523"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "fun main(args: Array) {\n val divisor = 998244353\n\n val inputs = readLine()!!.split(\" \")\n val n = inputs[0].toInt()\n val a = inputs[1].toInt()\n val b = inputs[2].toInt()\n val k = inputs[3].toInt()\n\n val counts = mutableListOf>()\n for (green in 0..n) {\n for (red in 0..(n - green)) {\n for (blue in 0..(n - green - red)) {\n val point = a * red + (a + b) * green + b * blue\n if (point == k) {\n counts.add(Triple(red, green, blue))\n } else if (point > k) {\n break\n }\n }\n }\n }\n\n val sum = counts.map {\n val red = it.first\n val green = it.second\n val blue = it.third\n c(n, red) * c(n - red, green) * c(n - red - green, blue)\n }.sum()\n\n println(sum % divisor)\n}\n\nfun c(x: Int, y: Int): Int {\n if (y == 0) {\n return 1\n }\n// println(\"x=$x, y=$y, answer=${((x - y + 1)..x).reduce(Int::times) / (1..y).reduce(Int::times)}\")\n return ((x - y + 1)..x).reduce(Int::times) / (1..y).reduce(Int::times)\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi has a tower which is divided into N layers.\nInitially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.\nHe defines the beauty of the tower as follows:\n\nThe beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.\n\nHere, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.\n\nTakahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.\nHow many such ways are there to paint the tower? Find the count modulo 998244353.\nTwo ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.\n\nConstraints\n\n1 ≤ N ≤ 3×10^5\n\n1 ≤ A,B ≤ 3×10^5\n\n0 ≤ K ≤ 18×10^{10}\n\nAll values in the input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B K\n\nOutput\n\nPrint the number of the ways to paint tiles, modulo 998244353.\n\nSample Input 1\n\n4 1 2 5\n\nSample Output 1\n\n40\n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:\n\n1 green, 1 blue\n\n1 red, 2 blues\n\n2 reds, 1 green\n\n3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\nSample Input 2\n\n2 5 6 0\n\nSample Output 2\n\n1\n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.\n\nSample Input 3\n\n90081 33447 90629 6391049189\n\nSample Output 3\n\n577742975", "sample_input": "4 1 2 5\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03332", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi has a tower which is divided into N layers.\nInitially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.\nHe defines the beauty of the tower as follows:\n\nThe beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.\n\nHere, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.\n\nTakahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.\nHow many such ways are there to paint the tower? Find the count modulo 998244353.\nTwo ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.\n\nConstraints\n\n1 ≤ N ≤ 3×10^5\n\n1 ≤ A,B ≤ 3×10^5\n\n0 ≤ K ≤ 18×10^{10}\n\nAll values in the input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B K\n\nOutput\n\nPrint the number of the ways to paint tiles, modulo 998244353.\n\nSample Input 1\n\n4 1 2 5\n\nSample Output 1\n\n40\n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:\n\n1 green, 1 blue\n\n1 red, 2 blues\n\n2 reds, 1 green\n\n3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\nSample Input 2\n\n2 5 6 0\n\nSample Output 2\n\n1\n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.\n\nSample Input 3\n\n90081 33447 90629 6391049189\n\nSample Output 3\n\n577742975", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1132, "cpu_time_ms": 2111, "memory_kb": 37864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s236749434", "group_id": "codeNet:p03346", "input_text": "import java.util.*\n\nprivate fun readStrings() = readLine()!!.split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n val N = readInts()[0]\n val p = (1 .. N).map { readInts()[0] }\n\n val series = HashMap()\n p.forEach {\n if (series.containsKey(it - 1)) {\n series[it] = series.remove(it - 1)!! + 1\n } else {\n series[it] = 1\n }\n }\n println(N - series.values.max()!!)\n}", "language": "Kotlin", "metadata": {"date": 1526870786, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03346.html", "problem_id": "p03346", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03346/input.txt", "sample_output_relpath": "derived/input_output/data/p03346/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03346/Kotlin/s236749434.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s236749434", "user_id": "u909304507"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nprivate fun readStrings() = readLine()!!.split(\" \")\nprivate fun readInts() = readStrings().map { it.toInt() }\n\nfun main(args: Array) {\n val N = readInts()[0]\n val p = (1 .. N).map { readInts()[0] }\n\n val series = HashMap()\n p.forEach {\n if (series.containsKey(it - 1)) {\n series[it] = series.remove(it - 1)!! + 1\n } else {\n series[it] = 1\n }\n }\n println(N - series.values.max()!!)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N.\nYou would like to sort this sequence in ascending order by repeating the following operation:\n\nChoose an element in the sequence and move it to the beginning or the end of the sequence.\n\nFind the minimum number of operations required.\nIt can be proved that it is actually possible to sort the sequence using this operation.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n(P_1,P_2,...,P_N) is a permutation of (1,2,...,N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1\n:\nP_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\n1\n3\n2\n4\n\nSample Output 1\n\n2\n\nFor example, the sequence can be sorted in ascending order as follows:\n\nMove 2 to the beginning. The sequence is now (2,1,3,4).\n\nMove 1 to the beginning. The sequence is now (1,2,3,4).\n\nSample Input 2\n\n6\n3\n2\n5\n1\n4\n6\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\n6\n3\n1\n2\n7\n4\n8\n5\n\nSample Output 3\n\n5", "sample_input": "4\n1\n3\n2\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03346", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N.\nYou would like to sort this sequence in ascending order by repeating the following operation:\n\nChoose an element in the sequence and move it to the beginning or the end of the sequence.\n\nFind the minimum number of operations required.\nIt can be proved that it is actually possible to sort the sequence using this operation.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n(P_1,P_2,...,P_N) is a permutation of (1,2,...,N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1\n:\nP_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\n1\n3\n2\n4\n\nSample Output 1\n\n2\n\nFor example, the sequence can be sorted in ascending order as follows:\n\nMove 2 to the beginning. The sequence is now (2,1,3,4).\n\nMove 1 to the beginning. The sequence is now (1,2,3,4).\n\nSample Input 2\n\n6\n3\n2\n5\n1\n4\n6\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\n6\n3\n1\n2\n7\n4\n8\n5\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 481, "cpu_time_ms": 677, "memory_kb": 74656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s689398529", "group_id": "codeNet:p03351", "input_text": "import java.util.*\n\nval scanner = Scanner(System.`in`)\n\nfun main(args: Array) {\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val c = scanner.nextInt()\n val d = scanner.nextInt()\n\n val direct = Math.abs(a - c) <= d\n val indirect = Math.abs(a - b) <= d || Math.abs(b - c) <= d\n\n println(if (direct || indirect) \"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1526174080, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/Kotlin/s689398529.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s689398529", "user_id": "u963316883"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nval scanner = Scanner(System.`in`)\n\nfun main(args: Array) {\n val a = scanner.nextInt()\n val b = scanner.nextInt()\n val c = scanner.nextInt()\n val d = scanner.nextInt()\n\n val direct = Math.abs(a - c) <= d\n val indirect = Math.abs(a - b) <= d || Math.abs(b - c) <= d\n\n println(if (direct || indirect) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 183, "memory_kb": 29604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s656103937", "group_id": "codeNet:p03352", "input_text": "fun main(args:Array) {\n val b = Math.sqrt(readLine()!!.toDouble()).toInt()\n println( b*b )\n}", "language": "Kotlin", "metadata": {"date": 1526261215, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Kotlin/s656103937.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s656103937", "user_id": "u693048766"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args:Array) {\n val b = Math.sqrt(readLine()!!.toDouble()).toInt()\n println( b*b )\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 102, "cpu_time_ms": 204, "memory_kb": 31784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s071413818", "group_id": "codeNet:p03353", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n val k = sc.nextInt()\n println(problem097c(s, k))\n}\n\nfun problem097c(s: String, k: Int): String {\n val set = mutableSetOf()\n fun subStringGenerator(current: String, index: Int) {\n set.add(current)\n if (index == s.length - 1) return\n if (current.length > k) return\n subStringGenerator(s[index + 1].toString(), index + 1)\n subStringGenerator(current + s[index + 1], index + 1)\n }\n subStringGenerator(s[0].toString(), 0)\n return set.sorted()[k - 1]\n}", "language": "Kotlin", "metadata": {"date": 1590720878, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03353.html", "problem_id": "p03353", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03353/input.txt", "sample_output_relpath": "derived/input_output/data/p03353/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03353/Kotlin/s071413818.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s071413818", "user_id": "u073232808"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n val k = sc.nextInt()\n println(problem097c(s, k))\n}\n\nfun problem097c(s: String, k: Int): String {\n val set = mutableSetOf()\n fun subStringGenerator(current: String, index: Int) {\n set.add(current)\n if (index == s.length - 1) return\n if (current.length > k) return\n subStringGenerator(s[index + 1].toString(), index + 1)\n subStringGenerator(current + s[index + 1], index + 1)\n }\n subStringGenerator(s[0].toString(), 0)\n return set.sorted()[k - 1]\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03353", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 619, "cpu_time_ms": 2111, "memory_kb": 120340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s312192704", "group_id": "codeNet:p03353", "input_text": "fun main(args: Array) {\n var s = readLine()!!\n var K = readLine()!!.toInt()\n var a = (0..s.length-1).map{i->\n (0..s.length-1).map{j->\n s.slice(i..j)\n }\n\n }.flatten().toSet().filter{it.length<=K && it!=\"\"}.sorted()\n println(a[K-1])\n}\n", "language": "Kotlin", "metadata": {"date": 1554742891, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03353.html", "problem_id": "p03353", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03353/input.txt", "sample_output_relpath": "derived/input_output/data/p03353/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03353/Kotlin/s312192704.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s312192704", "user_id": "u399261731"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "fun main(args: Array) {\n var s = readLine()!!\n var K = readLine()!!.toInt()\n var a = (0..s.length-1).map{i->\n (0..s.length-1).map{j->\n s.slice(i..j)\n }\n\n }.flatten().toSet().filter{it.length<=K && it!=\"\"}.sorted()\n println(a[K-1])\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03353", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 313, "cpu_time_ms": 868, "memory_kb": 301608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s626169308", "group_id": "codeNet:p03360", "input_text": "fun main(args: Array) {\n var x = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n var k = readLine()!!.toInt()\n (1..k).map{\n x[x.indexOf(x.max()!!)] *= 2\n } \n println(x.sum())\n}\n", "language": "Kotlin", "metadata": {"date": 1554646539, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03360/input.txt", "sample_output_relpath": "derived/input_output/data/p03360/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03360/Kotlin/s626169308.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s626169308", "user_id": "u399261731"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "fun main(args: Array) {\n var x = readLine()!!.split(\" \").map(String::toInt).toMutableList()\n var k = readLine()!!.toInt()\n (1..k).map{\n x[x.indexOf(x.max()!!)] *= 2\n } \n println(x.sum())\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "sample_input": "5 3 11\n1\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03360", "source_text": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 222, "cpu_time_ms": 248, "memory_kb": 37920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s324058902", "group_id": "codeNet:p03361", "input_text": "fun main(args: Array) {\n val (h, w) = readIntList()\n val s = List(h) { readString() }\n\n for (i in 0 until h) {\n for (j in 0 until w) {\n if (s[i][j] == '.') {\n continue\n }\n var ok = false\n if (i - 1 >= 0 && s[i - 1][j] == '#') ok = true\n if (i + 1 < h && s[i + 1][j] == '#') ok = true\n if (j - 1 >= 0 && s[i][j - 1] == '#') ok = true\n if (j + 1 < w && s[i][j + 1] == '#') ok = true\n if (!ok) {\n println(\"No\")\n return\n }\n }\n }\n println(\"Yes\")\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "language": "Kotlin", "metadata": {"date": 1596071953, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Kotlin/s324058902.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s324058902", "user_id": "u697467902"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val (h, w) = readIntList()\n val s = List(h) { readString() }\n\n for (i in 0 until h) {\n for (j in 0 until w) {\n if (s[i][j] == '.') {\n continue\n }\n var ok = false\n if (i - 1 >= 0 && s[i - 1][j] == '#') ok = true\n if (i + 1 < h && s[i + 1][j] == '#') ok = true\n if (j - 1 >= 0 && s[i][j - 1] == '#') ok = true\n if (j + 1 < w && s[i][j + 1] == '#') ok = true\n if (!ok) {\n println(\"No\")\n return\n }\n }\n }\n println(\"Yes\")\n}\n\n// Tools\nfun readString() = readLine()!!\nfun readInt() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntList() = readLine()!!.split(\" \").map(String::toInt)\nfun readLongList() = readLine()!!.split(\" \").map(String::toLong)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 916, "cpu_time_ms": 130, "memory_kb": 37960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s174605624", "group_id": "codeNet:p03361", "input_text": "fun main(args: Array) {\n var (h,w) = readLine()!!.split(\" \").map(String::toInt)\n var S = (1..h).map{\n readLine()!!.toList().map{it.toString()}\n } \n var size = (0..h-1).map{y->\n (0..w-1).map{x->\n var a = S[y][x]\n if(a == \"#\"){\n var list = mutableListOf()\n\n if(y!=0) list.add(S[y-1][x])\n if(x!=0) list.add(S[y][x-1])\n if(y!=h-1) list.add(S[y+1][x])\n if(x!=w-1) list.add(S[y][x+1])\n list.filter{it==\"#\"}.size >= 1\n }\n else null\n }\n }.flatten().filter{it==true}.size\n if(size !=0) println(\"Yes\")\n else println(\"No\")\n \n}\n", "language": "Kotlin", "metadata": {"date": 1554648141, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Kotlin/s174605624.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s174605624", "user_id": "u399261731"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n var (h,w) = readLine()!!.split(\" \").map(String::toInt)\n var S = (1..h).map{\n readLine()!!.toList().map{it.toString()}\n } \n var size = (0..h-1).map{y->\n (0..w-1).map{x->\n var a = S[y][x]\n if(a == \"#\"){\n var list = mutableListOf()\n\n if(y!=0) list.add(S[y-1][x])\n if(x!=0) list.add(S[y][x-1])\n if(y!=h-1) list.add(S[y+1][x])\n if(x!=w-1) list.add(S[y][x+1])\n list.filter{it==\"#\"}.size >= 1\n }\n else null\n }\n }.flatten().filter{it==true}.size\n if(size !=0) println(\"Yes\")\n else println(\"No\")\n \n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 886, "cpu_time_ms": 285, "memory_kb": 38644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s719355938", "group_id": "codeNet:p03363", "input_text": "fun main(args: Array) {\n solve(java.util.Scanner(System.`in`))\n}\n\n// 累積和\nfun sumList(a: List): List {\n val result = mutableListOf(0)\n var i = 0\n a.forEach {\n i += it\n result.add(i)\n }\n return result\n}\n\nfun countList(a: List): Map {\n val result = mutableMapOf()\n a.forEach {\n result[it] = (result[it] ?: 0) + 1\n }\n return result\n}\n\n\nfun solve(sc: java.util.Scanner) {\n val N = sc.nextInt()\n val A = Array(N) { sc.nextInt() }\n\n val S = sumList(A.toList())\n val C = countList(S)\n var result = 0\n C.forEach { ent ->\n result += (ent.value * (ent.value - 1)) / 2\n }\n println(result)\n}\n", "language": "Kotlin", "metadata": {"date": 1584678658, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03363/input.txt", "sample_output_relpath": "derived/input_output/data/p03363/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03363/Kotlin/s719355938.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s719355938", "user_id": "u297767059"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n solve(java.util.Scanner(System.`in`))\n}\n\n// 累積和\nfun sumList(a: List): List {\n val result = mutableListOf(0)\n var i = 0\n a.forEach {\n i += it\n result.add(i)\n }\n return result\n}\n\nfun countList(a: List): Map {\n val result = mutableMapOf()\n a.forEach {\n result[it] = (result[it] ?: 0) + 1\n }\n return result\n}\n\n\nfun solve(sc: java.util.Scanner) {\n val N = sc.nextInt()\n val A = Array(N) { sc.nextInt() }\n\n val S = sumList(A.toList())\n val C = countList(S)\n var result = 0\n C.forEach { ent ->\n result += (ent.value * (ent.value - 1)) / 2\n }\n println(result)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "sample_input": "6\n1 3 -4 2 2 -2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03363", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 710, "cpu_time_ms": 804, "memory_kb": 82672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s764758143", "group_id": "codeNet:p03363", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val AArr = readInputLine().split(\" \").map { it.toLong() }.toLongArray()\n val sumArr = LongArray(N)\n val sumArrCnt = mutableMapOf()\n sumArr[0] = AArr[0]\n sumArrCnt.put(sumArr[0], 1L)\n \n for (i in 1 until N) {\n sumArr[i] = sumArr[i - 1] + AArr[i]\n sumArrCnt.put(sumArr[i], (sumArrCnt.get(sumArr[i]) ?: 0L) + 1L)\n }\n \n var ans = 0L\n var sum = 0L\n\n for (i in 0 until N) {\n ans += sumArrCnt.get(sum) ?: 0L\n sumArrCnt.put(sumArr[i], sumArrCnt.get(sumArr[i])!! - 1L)\n sum += AArr[i]\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1572748921, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03363/input.txt", "sample_output_relpath": "derived/input_output/data/p03363/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03363/Kotlin/s764758143.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764758143", "user_id": "u505558493"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val AArr = readInputLine().split(\" \").map { it.toLong() }.toLongArray()\n val sumArr = LongArray(N)\n val sumArrCnt = mutableMapOf()\n sumArr[0] = AArr[0]\n sumArrCnt.put(sumArr[0], 1L)\n \n for (i in 1 until N) {\n sumArr[i] = sumArr[i - 1] + AArr[i]\n sumArrCnt.put(sumArr[i], (sumArrCnt.get(sumArr[i]) ?: 0L) + 1L)\n }\n \n var ans = 0L\n var sum = 0L\n\n for (i in 0 until N) {\n ans += sumArrCnt.get(sum) ?: 0L\n sumArrCnt.put(sumArr[i], sumArrCnt.get(sumArr[i])!! - 1L)\n sum += AArr[i]\n }\n\n println(ans)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "sample_input": "6\n1 3 -4 2 2 -2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03363", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 711, "cpu_time_ms": 887, "memory_kb": 107488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s273912923", "group_id": "codeNet:p03363", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map { it.toLong() }\n \n val cumsum = Array(n + 1) { 0L }\n val memo = mutableMapOf()\n memo[0] = 1\n for (i in 0 until an.size) {\n var sum = cumsum[i] + an[i]\n cumsum[i + 1] = sum\n\n memo[sum] = memo.getOrPut(sum) { 0 } + 1\n }\n\n val ans = memo.filter { it.value >= 2 }.map { it.value * (it.value - 1) / 2 }.sum();\n println(ans)\n\n}", "language": "Kotlin", "metadata": {"date": 1552700899, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03363/input.txt", "sample_output_relpath": "derived/input_output/data/p03363/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03363/Kotlin/s273912923.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273912923", "user_id": "u367259152"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val an = readLine()!!.split(\" \").map { it.toLong() }\n \n val cumsum = Array(n + 1) { 0L }\n val memo = mutableMapOf()\n memo[0] = 1\n for (i in 0 until an.size) {\n var sum = cumsum[i] + an[i]\n cumsum[i + 1] = sum\n\n memo[sum] = memo.getOrPut(sum) { 0 } + 1\n }\n\n val ans = memo.filter { it.value >= 2 }.map { it.value * (it.value - 1) / 2 }.sum();\n println(ans)\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "sample_input": "6\n1 3 -4 2 2 -2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03363", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 484, "cpu_time_ms": 908, "memory_kb": 111700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s632356415", "group_id": "codeNet:p03364", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nvar n: Int = 0\nvar s: Array = Array(0){\"\"}\n\nfun main(args: Array) = IO().exec {\n n = int()\n s = Array(n){string()}\n println((0 until n).map { isSyn(it) }.count { it } * n)\n}\n\nfun isSyn(sx: Int): Boolean {\n for (y in 0 until n) for (x in 0 until n)\n if (s[y][(x + sx) % n] != s[x][(sx + y) % n]) return false\n return true\n}\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = PrintWriter(System.out)\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun string(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun long(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun double(): Double {\n return string().toDouble()\n }\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}", "language": "Kotlin", "metadata": {"date": 1565180331, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03364/input.txt", "sample_output_relpath": "derived/input_output/data/p03364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03364/Kotlin/s632356415.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s632356415", "user_id": "u095834727"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nvar n: Int = 0\nvar s: Array = Array(0){\"\"}\n\nfun main(args: Array) = IO().exec {\n n = int()\n s = Array(n){string()}\n println((0 until n).map { isSyn(it) }.count { it } * n)\n}\n\nfun isSyn(sx: Int): Boolean {\n for (y in 0 until n) for (x in 0 until n)\n if (s[y][(x + sx) % n] != s[x][(sx + y) % n]) return false\n return true\n}\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = PrintWriter(System.out)\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun string(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun long(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun double(): Double {\n return string().toDouble()\n }\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2622, "cpu_time_ms": 395, "memory_kb": 34092}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s873784318", "group_id": "codeNet:p03369", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n println(700 + 100 * s.count { it == 'o' })\n}\n", "language": "Kotlin", "metadata": {"date": 1569263029, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03369/input.txt", "sample_output_relpath": "derived/input_output/data/p03369/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03369/Kotlin/s873784318.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s873784318", "user_id": "u863309603"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n println(700 + 100 * s.count { it == 'o' })\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 106, "cpu_time_ms": 215, "memory_kb": 33688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s345753519", "group_id": "codeNet:p03370", "input_text": "fun main(args: Array) {\n val (N,X) = readLine()!!.split(\" \").map { it.toInt() }\n val ms = (1..N).map { readLine()!!.toInt() }\n\n val ans = N + (X - ms.sum()) / ms.min()!!\n print(ans)\n}", "language": "Kotlin", "metadata": {"date": 1528248486, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03370.html", "problem_id": "p03370", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03370/input.txt", "sample_output_relpath": "derived/input_output/data/p03370/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03370/Kotlin/s345753519.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s345753519", "user_id": "u185034753"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (N,X) = readLine()!!.split(\" \").map { it.toInt() }\n val ms = (1..N).map { readLine()!!.toInt() }\n\n val ans = N + (X - ms.sum()) / ms.min()!!\n print(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "sample_input": "3 1000\n120\n100\n140\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03370", "source_text": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 240, "memory_kb": 37752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s484309973", "group_id": "codeNet:p03371", "input_text": "fun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(java.util.Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {\n val A = sc.next().toInt()\n val B = sc.next().toInt()\n val C = sc.next().toInt()\n val X = sc.next().toInt()\n val Y = sc.next().toInt()\n\n val c = when {\n A + B > C * 4 -> Math.max(X, Y) * 2\n A + B > C * 2 -> Math.min(X, Y) * 2\n else -> 0\n }\n val a = Math.max(X - c / 2, 0)\n val b = Math.max(Y - c / 2, 0)\n\n pw.println(A * a + B * b + C * c)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1585915056, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03371/input.txt", "sample_output_relpath": "derived/input_output/data/p03371/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03371/Kotlin/s484309973.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s484309973", "user_id": "u297767059"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "fun main(args: Array) {\n val pw = java.io.PrintWriter(System.out)\n Problem.solve(java.util.Scanner(System.`in`), pw)\n pw.flush()\n}\n\nobject Problem {\n fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {\n val A = sc.next().toInt()\n val B = sc.next().toInt()\n val C = sc.next().toInt()\n val X = sc.next().toInt()\n val Y = sc.next().toInt()\n\n val c = when {\n A + B > C * 4 -> Math.max(X, Y) * 2\n A + B > C * 2 -> Math.min(X, Y) * 2\n else -> 0\n }\n val a = Math.max(X - c / 2, 0)\n val b = Math.max(Y - c / 2, 0)\n\n pw.println(A * a + B * b + C * c)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 681, "cpu_time_ms": 189, "memory_kb": 29468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s499059873", "group_id": "codeNet:p03371", "input_text": "\nfun main(args:Array) {\n val inpt = readLine()!!.split(\" \").map { it.toInt() }\n val prc = Proc(inpt[0], inpt[1], inpt[2], inpt[3], inpt[4])\n println(prc.proc())\n}\n\n\nclass Proc(val a:Int, val b:Int, val c:Int, val x:Int, val y:Int) {\n fun proc():Int {\n return getAns(0, Math.max(x,y)*2)\n }\n\n fun getCost(mixCount:Int):Int {\n var ret = mixCount*c\n ret += Math.max(x - (mixCount/2), 0)*a\n ret += Math.max(y - (mixCount/2), 0)*b\n return ret\n }\n fun getAns(min:Int, max:Int):Int {\n if(max-min <= 2) {\n return listOf(min, (max+min)/2, max).map { getCost(it) }.min()!!\n }\n val idx1 = min + (max-min)/3\n val idx2 = idx1 + (max-min)/3\n val val1 = getCost(min)\n val val2 = getCost(idx1)\n val val3 = getCost(idx2)\n val val4 = getCost(max)\n val minVal = listOf(val1,val2,val3,val4).min()!!\n if(val1 == minVal) {\n return getAns(min, idx1)\n } else if(val2 == minVal) {\n return getAns(min, idx2)\n } else if(val3 == minVal) {\n return getAns(idx1, max)\n } else {\n return getAns(idx2, max)\n }\n }\n\n}\n", "language": "Kotlin", "metadata": {"date": 1578512564, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03371/input.txt", "sample_output_relpath": "derived/input_output/data/p03371/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03371/Kotlin/s499059873.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s499059873", "user_id": "u269969976"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "\nfun main(args:Array) {\n val inpt = readLine()!!.split(\" \").map { it.toInt() }\n val prc = Proc(inpt[0], inpt[1], inpt[2], inpt[3], inpt[4])\n println(prc.proc())\n}\n\n\nclass Proc(val a:Int, val b:Int, val c:Int, val x:Int, val y:Int) {\n fun proc():Int {\n return getAns(0, Math.max(x,y)*2)\n }\n\n fun getCost(mixCount:Int):Int {\n var ret = mixCount*c\n ret += Math.max(x - (mixCount/2), 0)*a\n ret += Math.max(y - (mixCount/2), 0)*b\n return ret\n }\n fun getAns(min:Int, max:Int):Int {\n if(max-min <= 2) {\n return listOf(min, (max+min)/2, max).map { getCost(it) }.min()!!\n }\n val idx1 = min + (max-min)/3\n val idx2 = idx1 + (max-min)/3\n val val1 = getCost(min)\n val val2 = getCost(idx1)\n val val3 = getCost(idx2)\n val val4 = getCost(max)\n val minVal = listOf(val1,val2,val3,val4).min()!!\n if(val1 == minVal) {\n return getAns(min, idx1)\n } else if(val2 == minVal) {\n return getAns(min, idx2)\n } else if(val3 == minVal) {\n return getAns(idx1, max)\n } else {\n return getAns(idx2, max)\n }\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1204, "cpu_time_ms": 234, "memory_kb": 37648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s730192982", "group_id": "codeNet:p03371", "input_text": "fun main(args: Array) {\n val (A, B, C, X, Y) = readLine()!!.split(\" \").map { it.toLong() }\n\n //\n\n // assume buying C * 2i\n var sum = X * A + Y * B\n var min = sum\n var a = X\n var b = Y\n var c = 0L\n while (!(a == 0L && b == 0L)) {\n if (a > 0) {\n sum = sum - A\n a--\n }\n\n if (b > 0) {\n sum = sum - B\n b--\n }\n c += 2\n sum = sum + C * 2\n min = Math.min(min, sum)\n }\n println(min)\n}\n", "language": "Kotlin", "metadata": {"date": 1569100067, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03371/input.txt", "sample_output_relpath": "derived/input_output/data/p03371/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03371/Kotlin/s730192982.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730192982", "user_id": "u861095163"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "fun main(args: Array) {\n val (A, B, C, X, Y) = readLine()!!.split(\" \").map { it.toLong() }\n\n //\n\n // assume buying C * 2i\n var sum = X * A + Y * B\n var min = sum\n var a = X\n var b = Y\n var c = 0L\n while (!(a == 0L && b == 0L)) {\n if (a > 0) {\n sum = sum - A\n a--\n }\n\n if (b > 0) {\n sum = sum - B\n b--\n }\n c += 2\n sum = sum + C * 2\n min = Math.min(min, sum)\n }\n println(min)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 510, "cpu_time_ms": 249, "memory_kb": 37936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s721450356", "group_id": "codeNet:p03377", "input_text": "fun main(args : Array) {\n print(readLine()!!.split(\" \").map { it.toInt() }.let { if (it[2] < it[0] || it[2] > it[0] + it[1]) \"NO\" else \"YES\" })\n}", "language": "Kotlin", "metadata": {"date": 1526933220, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03377.html", "problem_id": "p03377", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03377/input.txt", "sample_output_relpath": "derived/input_output/data/p03377/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03377/Kotlin/s721450356.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721450356", "user_id": "u384476909"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args : Array) {\n print(readLine()!!.split(\" \").map { it.toInt() }.let { if (it[2] < it[0] || it[2] > it[0] + it[1]) \"NO\" else \"YES\" })\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "sample_input": "3 5 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03377", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 236, "memory_kb": 37748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s312272838", "group_id": "codeNet:p03378", "input_text": "fun main(args: Array){\n val (n, m, x) = readLine()!!.split(' ').map{ it.toInt() }\n val a = readLine()!!.split(' ').map { it.toInt() }\n val left = a.count{ it < x}\n val right = a.count{ it > x}\n println(Math.min(left, right))\n}", "language": "Kotlin", "metadata": {"date": 1563283593, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03378.html", "problem_id": "p03378", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03378/input.txt", "sample_output_relpath": "derived/input_output/data/p03378/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03378/Kotlin/s312272838.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312272838", "user_id": "u089528214"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array){\n val (n, m, x) = readLine()!!.split(' ').map{ it.toInt() }\n val a = readLine()!!.split(' ').map { it.toInt() }\n val left = a.count{ it < x}\n val right = a.count{ it > x}\n println(Math.min(left, right))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "sample_input": "5 3 3\n1 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03378", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 249, "cpu_time_ms": 237, "memory_kb": 38364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s787867266", "group_id": "codeNet:p03378", "input_text": "fun main(args: Array) {\n val (N, M, X) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toInt() }\n\n val road = (1..N).map { if (A.contains(it)) 1 else 0 }.toList()\n val leftCost = (0 until X).map { road[it] }.sum()\n val rightCost = (X until N).map { road[it] }.sum()\n \n println(Math.min(leftCost, rightCost))\n}", "language": "Kotlin", "metadata": {"date": 1531938765, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03378.html", "problem_id": "p03378", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03378/input.txt", "sample_output_relpath": "derived/input_output/data/p03378/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03378/Kotlin/s787867266.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s787867266", "user_id": "u963316883"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, M, X) = readLine()!!.split(\" \").map { it.toInt() }\n val A = readLine()!!.split(\" \").map { it.toInt() }\n\n val road = (1..N).map { if (A.contains(it)) 1 else 0 }.toList()\n val leftCost = (0 until X).map { road[it] }.sum()\n val rightCost = (X until N).map { road[it] }.sum()\n \n println(Math.min(leftCost, rightCost))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "sample_input": "5 3 3\n1 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03378", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 377, "cpu_time_ms": 252, "memory_kb": 36060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494340065", "group_id": "codeNet:p03379", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val X = (0 until N).map { sc.nextLong() }\n\n val Xs = X.sorted()\n val midL = Xs[N / 2 - 1]\n val midR = Xs[N / 2]\n\n for (i in 0 until N) {\n println(if (X[i] < midR) midR else midL)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1585717046, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Kotlin/s494340065.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s494340065", "user_id": "u297767059"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val N = sc.nextInt()\n val X = (0 until N).map { sc.nextLong() }\n\n val Xs = X.sorted()\n val midL = Xs[N / 2 - 1]\n val midR = Xs[N / 2]\n\n for (i in 0 until N) {\n println(if (X[i] < midR) midR else midL)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 2111, "memory_kb": 84556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s597248683", "group_id": "codeNet:p03379", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val X = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val sorted = X.sorted()\n\n val a = Math.floor((1.toDouble() + N.toDouble()) / 2.0).toInt() - 1\n val b = Math.ceil((1.toDouble() + N.toDouble()) / 2.0).toInt() - 1\n for (i in 0 until N) {\n if (X[i] <= sorted[a]) {\n println(sorted[b])\n } else {\n println(sorted[a])\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1569816049, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Kotlin/s597248683.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597248683", "user_id": "u861095163"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val X = readLine()!!.split(\" \").map { it.toInt() }.toIntArray()\n val sorted = X.sorted()\n\n val a = Math.floor((1.toDouble() + N.toDouble()) / 2.0).toInt() - 1\n val b = Math.ceil((1.toDouble() + N.toDouble()) / 2.0).toInt() - 1\n for (i in 0 until N) {\n if (X[i] <= sorted[a]) {\n println(sorted[b])\n } else {\n println(sorted[a])\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 461, "cpu_time_ms": 1975, "memory_kb": 98568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s669431025", "group_id": "codeNet:p03379", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n \n val Xs = readInputLine().split(\" \").map {it.toInt()}\n \n val (lower, higher) = Xs.sorted().toIntArray().let {Pair(it[N / 2 - 1], it[N / 2])}\n \n for (x in Xs) {\n if (x >= higher) {\n println(lower)\n } else {\n println(higher)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565787114, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Kotlin/s669431025.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s669431025", "user_id": "u505558493"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n \n val Xs = readInputLine().split(\" \").map {it.toInt()}\n \n val (lower, higher) = Xs.sorted().toIntArray().let {Pair(it[N / 2 - 1], it[N / 2])}\n \n for (x in Xs) {\n if (x >= higher) {\n println(lower)\n } else {\n println(higher)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 422, "cpu_time_ms": 2023, "memory_kb": 98604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s338556404", "group_id": "codeNet:p03379", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n \n val Xs = readInputLine().split(\" \").map {it.toInt()}\n \n val (lower, higher) = Xs.sorted().let {Pair(it[N / 2 - 1], it[N / 2])}\n \n for (x in Xs) {\n if (x >= higher) {\n println(lower)\n } else {\n println(higher)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1565786986, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Kotlin/s338556404.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s338556404", "user_id": "u505558493"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n \n val Xs = readInputLine().split(\" \").map {it.toInt()}\n \n val (lower, higher) = Xs.sorted().let {Pair(it[N / 2 - 1], it[N / 2])}\n \n for (x in Xs) {\n if (x >= higher) {\n println(lower)\n } else {\n println(higher)\n }\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 409, "cpu_time_ms": 2054, "memory_kb": 98440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494104670", "group_id": "codeNet:p03379", "input_text": "fun c94(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val sortedNumList = numList.sorted()\n val firstMedIndex = (numList.size - 1) / 2\n val secondMedIndex = firstMedIndex + 1\n\n numList.forEach {\n if (it <= sortedNumList[firstMedIndex]) {\n println(sortedNumList[secondMedIndex])\n } else {\n println(sortedNumList[firstMedIndex])\n }\n }\n}\n\nfun main(args: Array) {\n c94(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "language": "Kotlin", "metadata": {"date": 1542332775, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Kotlin/s494104670.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s494104670", "user_id": "u227166381"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "fun c94(args: Array) {\n val numList = args[1].split(\" \").map { it.toInt() }\n val sortedNumList = numList.sorted()\n val firstMedIndex = (numList.size - 1) / 2\n val secondMedIndex = firstMedIndex + 1\n\n numList.forEach {\n if (it <= sortedNumList[firstMedIndex]) {\n println(sortedNumList[secondMedIndex])\n } else {\n println(sortedNumList[firstMedIndex])\n }\n }\n}\n\nfun main(args: Array) {\n c94(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 771, "cpu_time_ms": 2088, "memory_kb": 98840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s543313538", "group_id": "codeNet:p03386", "input_text": "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 k = sc.nextLong()\n println(problem093b(a, b, k))\n}\n\nfun problem093b(a: Long, b: Long, k: Long): String {\n val answers = mutableListOf()\n for (i in 0 until k) {\n val ai = a + i\n val bi = b - i\n if (ai == bi) {\n answers.add(ai)\n break\n }\n if (ai > bi) {\n break\n }\n answers.add(ai)\n answers.add(bi)\n }\n return answers.sorted().joinToString(\"\\n\")\n}", "language": "Kotlin", "metadata": {"date": 1574743486, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03386.html", "problem_id": "p03386", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03386/input.txt", "sample_output_relpath": "derived/input_output/data/p03386/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03386/Kotlin/s543313538.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s543313538", "user_id": "u073232808"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "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 k = sc.nextLong()\n println(problem093b(a, b, k))\n}\n\nfun problem093b(a: Long, b: Long, k: Long): String {\n val answers = mutableListOf()\n for (i in 0 until k) {\n val ai = a + i\n val bi = b - i\n if (ai == bi) {\n answers.add(ai)\n break\n }\n if (ai > bi) {\n break\n }\n answers.add(ai)\n answers.add(bi)\n }\n return answers.sorted().joinToString(\"\\n\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "sample_input": "3 8 2\n"}, "reference_outputs": ["3\n4\n7\n8\n"], "source_document_id": "p03386", "source_text": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 600, "cpu_time_ms": 228, "memory_kb": 34372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s931428527", "group_id": "codeNet:p03386", "input_text": "fun main(args: Array) {\n val (a, b, k) = readLine()!!.split(\" \").map(String::toInt)\n if (b - a < 2 * k) {\n for (i in a..b) println(i)\n } else {\n for (i in 0 until k) {\n println(a + i)\n }\n for (i in 0 until k) {\n println(b - k + i + 1)\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1528255398, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03386.html", "problem_id": "p03386", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03386/input.txt", "sample_output_relpath": "derived/input_output/data/p03386/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03386/Kotlin/s931428527.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s931428527", "user_id": "u099066216"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, k) = readLine()!!.split(\" \").map(String::toInt)\n if (b - a < 2 * k) {\n for (i in a..b) println(i)\n } else {\n for (i in 0 until k) {\n println(a + i)\n }\n for (i in 0 until k) {\n println(b - k + i + 1)\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "sample_input": "3 8 2\n"}, "reference_outputs": ["3\n4\n7\n8\n"], "source_document_id": "p03386", "source_text": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 239, "memory_kb": 37872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s208454104", "group_id": "codeNet:p03389", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n val max3 = 3 * Math.max(a, Math.max(b, c))\n val sum = a + b + c\n if ((max3 % 2 == 1) && (sum % 2 == 0)\n || (max3 % 2 == 0) && (sum % 2 == 1)) {\n println((max3 + 3 - sum) / 2)\n } else {\n println((max3 - sum) / 2)\n }\n}", "language": "Kotlin", "metadata": {"date": 1528677516, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03389.html", "problem_id": "p03389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03389/input.txt", "sample_output_relpath": "derived/input_output/data/p03389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03389/Kotlin/s208454104.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s208454104", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(' ').map(String::toInt)\n val max3 = 3 * Math.max(a, Math.max(b, c))\n val sum = a + b + c\n if ((max3 % 2 == 1) && (sum % 2 == 0)\n || (max3 % 2 == 0) && (sum % 2 == 1)) {\n println((max3 + 3 - sum) / 2)\n } else {\n println((max3 - sum) / 2)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "sample_input": "2 5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03389", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 352, "cpu_time_ms": 350, "memory_kb": 38300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s021757811", "group_id": "codeNet:p03393", "input_text": "\nfun main(args:Array) {\n val s = readLine()!!.toMutableList()\n\n if(s.size == s.distinct().size) {\n if(s.size < 26) {\n for(i in ('a'..'z')) {\n if(s.contains(i)) {\n continue\n }\n s.add(i)\n println(s.joinToString(\"\"))\n return\n }\n }\n }\n println(getAns(s))\n}\n\nfun getAns(target:MutableList): String {\n for(i in (0 .. target.lastIndex).reversed()) {\n if(target[i] == 'z') {\n continue\n }\n if(i == 0) {\n return (target[0] + 1).toString()\n }\n val sub = target.subList(0, i)\n if(sub.size != sub.distinct().size) {\n continue\n }\n for(j in (target[i]+1..'z')) {\n if(sub.contains(j)) {\n continue\n }\n sub.add(j)\n return sub.joinToString(\"\")\n }\n }\n return \"-1\"\n}\n", "language": "Kotlin", "metadata": {"date": 1591291800, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03393.html", "problem_id": "p03393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03393/input.txt", "sample_output_relpath": "derived/input_output/data/p03393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03393/Kotlin/s021757811.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s021757811", "user_id": "u269969976"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "\nfun main(args:Array) {\n val s = readLine()!!.toMutableList()\n\n if(s.size == s.distinct().size) {\n if(s.size < 26) {\n for(i in ('a'..'z')) {\n if(s.contains(i)) {\n continue\n }\n s.add(i)\n println(s.joinToString(\"\"))\n return\n }\n }\n }\n println(getAns(s))\n}\n\nfun getAns(target:MutableList): String {\n for(i in (0 .. target.lastIndex).reversed()) {\n if(target[i] == 'z') {\n continue\n }\n if(i == 0) {\n return (target[0] + 1).toString()\n }\n val sub = target.subList(0, i)\n if(sub.size != sub.distinct().size) {\n continue\n }\n for(j in (target[i]+1..'z')) {\n if(sub.contains(j)) {\n continue\n }\n sub.add(j)\n return sub.joinToString(\"\")\n }\n }\n return \"-1\"\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "sample_input": "atcoder\n"}, "reference_outputs": ["atcoderb\n"], "source_document_id": "p03393", "source_text": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 966, "cpu_time_ms": 223, "memory_kb": 31896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s722708470", "group_id": "codeNet:p03393", "input_text": "import java.util.*\nfun main(args: Array) {\n val v = readLine()!!\n for (c in 'a'..'z') {\n if (v.indexOf(c) < 0) {\n println(v + c)\n }\n }\n val set = TreeSet()\n set.add(v.last())\n\n for (i in v.length - 2 downTo 0) {\n val c = v[i]\n val h = set.higher(c)\n if (h != null) {\n println(v.substring(0, i) + h)\n return\n }\n set.add(c)\n }\n println(-1)\n}", "language": "Kotlin", "metadata": {"date": 1538183124, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03393.html", "problem_id": "p03393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03393/input.txt", "sample_output_relpath": "derived/input_output/data/p03393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03393/Kotlin/s722708470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s722708470", "user_id": "u099066216"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "import java.util.*\nfun main(args: Array) {\n val v = readLine()!!\n for (c in 'a'..'z') {\n if (v.indexOf(c) < 0) {\n println(v + c)\n }\n }\n val set = TreeSet()\n set.add(v.last())\n\n for (i in v.length - 2 downTo 0) {\n val c = v[i]\n val h = set.higher(c)\n if (h != null) {\n println(v.substring(0, i) + h)\n return\n }\n set.add(c)\n }\n println(-1)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "sample_input": "atcoder\n"}, "reference_outputs": ["atcoderb\n"], "source_document_id": "p03393", "source_text": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 459, "cpu_time_ms": 211, "memory_kb": 34036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s862476540", "group_id": "codeNet:p03399", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n println(Math.min(a, b) + Math.min(c, d))\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582600546, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03399.html", "problem_id": "p03399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03399/input.txt", "sample_output_relpath": "derived/input_output/data/p03399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03399/Kotlin/s862476540.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s862476540", "user_id": "u194412908"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val a = sc.nextInt()\n val b = sc.nextInt()\n val c = sc.nextInt()\n val d = sc.nextInt()\n println(Math.min(a, b) + Math.min(c, d))\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "sample_input": "600\n300\n220\n420\n"}, "reference_outputs": ["520\n"], "source_document_id": "p03399", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2927, "cpu_time_ms": 164, "memory_kb": 31656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s398452420", "group_id": "codeNet:p03400", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = sc.nextInt()\n var x = sc.nextInt()\n\n repeat(n) {\n val a = sc.nextInt()\n x += 1 + (d - 1) / a\n }\n println(x)\n}\n", "language": "Kotlin", "metadata": {"date": 1541891556, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03400/input.txt", "sample_output_relpath": "derived/input_output/data/p03400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03400/Kotlin/s398452420.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398452420", "user_id": "u323680411"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val d = sc.nextInt()\n var x = sc.nextInt()\n\n repeat(n) {\n val a = sc.nextInt()\n x += 1 + (d - 1) / a\n }\n println(x)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "sample_input": "3\n7 1\n2\n5\n10\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03400", "source_text": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 195, "memory_kb": 31640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s617884524", "group_id": "codeNet:p03402", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val ans = Array(100) { CharArray(100) }\n\n // 上半分全部黒 下 白\n\n for (i in 0 until 100) {\n for (j in 0 until 100) {\n ans[i][j] = if (i < 50) {\n '#'\n } else {\n '.'\n }\n }\n }\n\n for (i in 0 until a - 1) {\n // よこ 最大数 50\n val yy = (i / 50) * 2\n val xx = (i % 50) * 2\n\n ans[yy][xx] = '.'\n }\n\n for (i in 0 until b - 1) {\n val yy = (i / 50) *2 + 51\n val xx = (i%50) * 2\n\n ans[yy][xx] = '#'\n\n }\n\n println(ans.joinToString(\"\\n\") { String(it) })\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582602397, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03402.html", "problem_id": "p03402", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03402/input.txt", "sample_output_relpath": "derived/input_output/data/p03402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03402/Kotlin/s617884524.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s617884524", "user_id": "u194412908"}, "prompt_components": {"gold_output": "3 3\n##.\n..#\n#.#\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val ans = Array(100) { CharArray(100) }\n\n // 上半分全部黒 下 白\n\n for (i in 0 until 100) {\n for (j in 0 until 100) {\n ans[i][j] = if (i < 50) {\n '#'\n } else {\n '.'\n }\n }\n }\n\n for (i in 0 until a - 1) {\n // よこ 最大数 50\n val yy = (i / 50) * 2\n val xx = (i % 50) * 2\n\n ans[yy][xx] = '.'\n }\n\n for (i in 0 until b - 1) {\n val yy = (i / 50) *2 + 51\n val xx = (i%50) * 2\n\n ans[yy][xx] = '#'\n\n }\n\n println(ans.joinToString(\"\\n\") { String(it) })\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "sample_input": "2 3\n"}, "reference_outputs": ["3 3\n##.\n..#\n#.#\n"], "source_document_id": "p03402", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3520, "cpu_time_ms": 213, "memory_kb": 34216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s934675065", "group_id": "codeNet:p03404", "input_text": "fun main(args: Array) {\n val (wCount, bCount) = readLine()!!.split(\" \").map(String::toInt)\n var wRemaining = wCount - 1\n var bRemaining = bCount - 1\n \n println(\"98 99\")\n \n for (y in 0 until 49) {\n if (y % 2 == 0) {\n println(String(CharArray(99, { '#' })))\n } else {\n val chars = CharArray(99, { '#' })\n for (x in 0 until 99) {\n if (x % 2 == 1) {\n if (wRemaining > 0) {\n chars[x] = '.'\n wRemaining--\n }\n }\n }\n println(String(chars))\n }\n }\n\n for (y in 0 until 49) {\n if (y % 2 == 0) {\n println(String(CharArray(99, { '.' })))\n } else {\n val chars = CharArray(99, { '.' })\n for (x in 0 until 99) {\n if (x % 2 == 1) {\n if (bRemaining > 0) {\n chars[x] = '#'\n bRemaining--\n }\n }\n }\n println(String(chars))\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1522027565, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03404.html", "problem_id": "p03404", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03404/input.txt", "sample_output_relpath": "derived/input_output/data/p03404/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03404/Kotlin/s934675065.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s934675065", "user_id": "u771276542"}, "prompt_components": {"gold_output": "3 3\n##.\n..#\n#.#\n", "input_to_evaluate": "fun main(args: Array) {\n val (wCount, bCount) = readLine()!!.split(\" \").map(String::toInt)\n var wRemaining = wCount - 1\n var bRemaining = bCount - 1\n \n println(\"98 99\")\n \n for (y in 0 until 49) {\n if (y % 2 == 0) {\n println(String(CharArray(99, { '#' })))\n } else {\n val chars = CharArray(99, { '#' })\n for (x in 0 until 99) {\n if (x % 2 == 1) {\n if (wRemaining > 0) {\n chars[x] = '.'\n wRemaining--\n }\n }\n }\n println(String(chars))\n }\n }\n\n for (y in 0 until 49) {\n if (y % 2 == 0) {\n println(String(CharArray(99, { '.' })))\n } else {\n val chars = CharArray(99, { '.' })\n for (x in 0 until 99) {\n if (x % 2 == 1) {\n if (bRemaining > 0) {\n chars[x] = '#'\n bRemaining--\n }\n }\n }\n println(String(chars))\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "sample_input": "2 3\n"}, "reference_outputs": ["3 3\n##.\n..#\n#.#\n"], "source_document_id": "p03404", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 901, "cpu_time_ms": 281, "memory_kb": 38028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s829166378", "group_id": "codeNet:p03407", "input_text": "fun main(args: Array) {\n val(a,b,c)= readLine()!!.split(\" \").map { it.toInt() }\n println(if(a+b>=c)\"Yes\" else \"No\")\n}", "language": "Kotlin", "metadata": {"date": 1541795508, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03407.html", "problem_id": "p03407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03407/input.txt", "sample_output_relpath": "derived/input_output/data/p03407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03407/Kotlin/s829166378.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829166378", "user_id": "u914096045"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val(a,b,c)= readLine()!!.split(\" \").map { it.toInt() }\n println(if(a+b>=c)\"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq A, B \\leq 500\n\n1 \\leq C \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf Takahashi can buy the toy, print Yes; if he cannot, print No.\n\nSample Input 1\n\n50 100 120\n\nSample Output 1\n\nYes\n\nHe has 50 + 100 = 150 yen, so he can buy the 120-yen toy.\n\nSample Input 2\n\n500 100 1000\n\nSample Output 2\n\nNo\n\nHe has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.\n\nSample Input 3\n\n19 123 143\n\nSample Output 3\n\nNo\n\nThere are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.\n\nSample Input 4\n\n19 123 142\n\nSample Output 4\n\nYes", "sample_input": "50 100 120\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03407", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq A, B \\leq 500\n\n1 \\leq C \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf Takahashi can buy the toy, print Yes; if he cannot, print No.\n\nSample Input 1\n\n50 100 120\n\nSample Output 1\n\nYes\n\nHe has 50 + 100 = 150 yen, so he can buy the 120-yen toy.\n\nSample Input 2\n\n500 100 1000\n\nSample Output 2\n\nNo\n\nHe has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.\n\nSample Input 3\n\n19 123 143\n\nSample Output 3\n\nNo\n\nThere are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.\n\nSample Input 4\n\n19 123 142\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 255, "memory_kb": 38032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s597456044", "group_id": "codeNet:p03408", "input_text": "fun main(args: Array) {\n val strings = mutableMapOf()\n val n = readLine()!!.toInt()\n repeat(n) {\n val s = readLine()!!\n if (s in strings) strings[s] = strings[s]!! + 1 else strings[s] = 1\n }\n val m = readLine()!!.toInt()\n repeat(m) {\n val s = readLine()!!\n if (s in strings) strings[s] = strings[s]!! - 1\n }\n println(Math.max(0, strings.values.max()!!))\n}\n", "language": "Kotlin", "metadata": {"date": 1558067649, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03408/input.txt", "sample_output_relpath": "derived/input_output/data/p03408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03408/Kotlin/s597456044.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597456044", "user_id": "u051841332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val strings = mutableMapOf()\n val n = readLine()!!.toInt()\n repeat(n) {\n val s = readLine()!!\n if (s in strings) strings[s] = strings[s]!! + 1 else strings[s] = 1\n }\n val m = readLine()!!.toInt()\n repeat(m) {\n val s = readLine()!!\n if (s in strings) strings[s] = strings[s]!! - 1\n }\n println(Math.max(0, strings.values.max()!!))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "sample_input": "3\napple\norange\napple\n1\ngrape\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03408", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 429, "cpu_time_ms": 210, "memory_kb": 33644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s187512413", "group_id": "codeNet:p03415", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val a = sc.next()\n val b = sc.next()\n val c = sc.next()\n\n println(sequenceOf(a[0], b[1], c[2]).joinToString(\"\"))\n}\n\n", "language": "Kotlin", "metadata": {"date": 1570941051, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03415.html", "problem_id": "p03415", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03415/input.txt", "sample_output_relpath": "derived/input_output/data/p03415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03415/Kotlin/s187512413.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187512413", "user_id": "u059223549"}, "prompt_components": {"gold_output": "abc\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = java.util.Scanner(System.`in`)\n val a = sc.next()\n val b = sc.next()\n val c = sc.next()\n\n println(sequenceOf(a[0], b[1], c[2]).joinToString(\"\"))\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "sample_input": "ant\nobe\nrec\n"}, "reference_outputs": ["abc\n"], "source_document_id": "p03415", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 225, "cpu_time_ms": 214, "memory_kb": 34128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s482779617", "group_id": "codeNet:p03417", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M) = nextLongList()\n val n = if (N == 1L) 1L else N - 2\n val m = if (M == 1L) 1L else M - 2\n println(n * m)\n}", "language": "Kotlin", "metadata": {"date": 1590374771, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03417/input.txt", "sample_output_relpath": "derived/input_output/data/p03417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03417/Kotlin/s482779617.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s482779617", "user_id": "u860789370"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (N, M) = nextLongList()\n val n = if (N == 1L) 1L else N - 2\n val m = if (M == 1L) 1L else M - 2\n println(n * m)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03417", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 665, "cpu_time_ms": 241, "memory_kb": 38000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s194489675", "group_id": "codeNet:p03418", "input_text": "import java.io.*\nimport java.util.*\n\n// N以下で a % b >= Kとなる(a,b)の組\nfun solve(N: Int, K: Int){\n if (K == 0){\n println(N*N)\n return\n }\n // a < b\n val ret1 = ((N-K+1)*(N-K))/ 2\n // a > b\n var ret2 = 0\n for (b in K + 1 until N){\n // a = b*x + r <= N -> x = 1,2, ... , (N-r)/b (K<=r<=b-1)\n for (r in K until b){\n ret2 += (N - r)/ b\n }\n }\n println(ret1+ret2)\n\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val K = sc.next().toInt()\n solve(N, K)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1564780796, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03418.html", "problem_id": "p03418", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03418/input.txt", "sample_output_relpath": "derived/input_output/data/p03418/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03418/Kotlin/s194489675.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s194489675", "user_id": "u329232967"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\n// N以下で a % b >= Kとなる(a,b)の組\nfun solve(N: Int, K: Int){\n if (K == 0){\n println(N*N)\n return\n }\n // a < b\n val ret1 = ((N-K+1)*(N-K))/ 2\n // a > b\n var ret2 = 0\n for (b in K + 1 until N){\n // a = b*x + r <= N -> x = 1,2, ... , (N-r)/b (K<=r<=b-1)\n for (r in K until b){\n ret2 += (N - r)/ b\n }\n }\n println(ret1+ret2)\n\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n val K = sc.next().toInt()\n solve(N, K)\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03418", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1071, "cpu_time_ms": 2111, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s092640975", "group_id": "codeNet:p03420", "input_text": "//\n\nfun main() {\n arc091b()\n}\n\nfun arc091b() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n if (k == 0) {\n println(n * n)\n return\n }\n var count = 0L\n for (b in k + 1 .. n) {\n val i = b - k\n val cycle = (n - k) / b\n count += cycle * i + i\n val over = cycle * b + k + i - 1\n if (over > n) {\n count -= (over - n)\n }\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1598114624, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03420.html", "problem_id": "p03420", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03420/input.txt", "sample_output_relpath": "derived/input_output/data/p03420/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03420/Kotlin/s092640975.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s092640975", "user_id": "u628907033"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "//\n\nfun main() {\n arc091b()\n}\n\nfun arc091b() {\n val (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n if (k == 0) {\n println(n * n)\n return\n }\n var count = 0L\n for (b in k + 1 .. n) {\n val i = b - k\n val cycle = (n - k) / b\n count += cycle * i + i\n val over = cycle * b + k + i - 1\n if (over > n) {\n count -= (over - n)\n }\n }\n println(count)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03420", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 437, "cpu_time_ms": 118, "memory_kb": 36452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s449248357", "group_id": "codeNet:p03425", "input_text": "import java.math.BigDecimal\n\nfun main(args: Array) {\n abc089c()\n}\n\nfun abc089c() {\n val n = readLine()!!.toInt()\n val initials = (1..n).map { readLine()!![0] }\n\n val march = Array(5) { BigDecimal(0) }\n\n march[0] = BigDecimal(initials.count { it == 'M' })\n march[1] = BigDecimal(initials.count { it == 'A' })\n march[2] = BigDecimal(initials.count { it == 'R' })\n march[3] = BigDecimal(initials.count { it == 'C' })\n march[4] = BigDecimal(initials.count { it == 'H' })\n\n val patterns = (0..4).map { i ->\n (i + 1..4).map { j ->\n (j + 1..4).map { k ->\n march[i] * march[j] * march[k]\n }\n }.flatten()\n }.flatten()\n\n val answer = patterns.fold(BigDecimal.ZERO, BigDecimal::add)\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1568505672, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03425.html", "problem_id": "p03425", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03425/input.txt", "sample_output_relpath": "derived/input_output/data/p03425/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03425/Kotlin/s449248357.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449248357", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.math.BigDecimal\n\nfun main(args: Array) {\n abc089c()\n}\n\nfun abc089c() {\n val n = readLine()!!.toInt()\n val initials = (1..n).map { readLine()!![0] }\n\n val march = Array(5) { BigDecimal(0) }\n\n march[0] = BigDecimal(initials.count { it == 'M' })\n march[1] = BigDecimal(initials.count { it == 'A' })\n march[2] = BigDecimal(initials.count { it == 'R' })\n march[3] = BigDecimal(initials.count { it == 'C' })\n march[4] = BigDecimal(initials.count { it == 'H' })\n\n val patterns = (0..4).map { i ->\n (i + 1..4).map { j ->\n (j + 1..4).map { k ->\n march[i] * march[j] * march[k]\n }\n }.flatten()\n }.flatten()\n\n val answer = patterns.fold(BigDecimal.ZERO, BigDecimal::add)\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "sample_input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03425", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 790, "cpu_time_ms": 358, "memory_kb": 37560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s215501707", "group_id": "codeNet:p03425", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val counts = IntArray(5)\n for (i in 0..n) {\n val line = sc.nextLine()\n when (line[0]) {\n 'M' -> ++counts[0]\n 'A' -> ++counts[1]\n 'R' -> ++counts[2]\n 'C' -> ++counts[3]\n 'H' -> ++counts[4]\n }\n }\n\n var ret:Long = 0L\n\n for (i in 0 until 5 - 2) {\n for (j in i + 1 until 5 - 1) {\n for (k in j + 1 until 5 - 0) {\n ret += counts[i] * counts[j] * counts[k]\n }\n }\n }\n\n println(ret)\n}\n", "language": "Kotlin", "metadata": {"date": 1520216611, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03425.html", "problem_id": "p03425", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03425/input.txt", "sample_output_relpath": "derived/input_output/data/p03425/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03425/Kotlin/s215501707.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s215501707", "user_id": "u151827661"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n\n val counts = IntArray(5)\n for (i in 0..n) {\n val line = sc.nextLine()\n when (line[0]) {\n 'M' -> ++counts[0]\n 'A' -> ++counts[1]\n 'R' -> ++counts[2]\n 'C' -> ++counts[3]\n 'H' -> ++counts[4]\n }\n }\n\n var ret:Long = 0L\n\n for (i in 0 until 5 - 2) {\n for (j in i + 1 until 5 - 1) {\n for (k in j + 1 until 5 - 0) {\n ret += counts[i] * counts[j] * counts[k]\n }\n }\n }\n\n println(ret)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "sample_input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03425", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 636, "cpu_time_ms": 186, "memory_kb": 29604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s013606162", "group_id": "codeNet:p03426", "input_text": "fun main(args: Array) {\n abc089d()\n}\n\nfun abc089d() {\n val (h, w, d) = readLine()!!.split(' ').map { it.toInt() }\n val grid = (1..h).map { readLine()!!.split(' ').map { it.toInt() - 1 } }\n val q = readLine()!!.toInt()\n val queries = (1..q)\n .map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }\n\n val gridSize = h * w\n val numberToId = mutableMapOf>()\n val minCosts = Array(gridSize) { y -> IntArray(gridSize) { x -> if (y == x) 0 else Int.MAX_VALUE / 100 } }\n\n for (y in 0 until h) {\n for (x in 0 until w) {\n numberToId[grid[y][x]] = y to x\n }\n }\n\n for (i in 0 until gridSize - d) {\n var currNum = i\n while (currNum + d < gridSize) {\n val fromXy = numberToId[currNum] ?: error(\"なんで?\")\n val toXy = numberToId[currNum + d] ?: error(\"なんで?\")\n minCosts[i][currNum + d] = minCosts[i][currNum] +\n Math.abs(fromXy.first - toXy.first) + Math.abs(fromXy.second - toXy.second)\n currNum += d\n }\n }\n\n val answer = queries.map { minCosts[it.first][it.second] }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1579843877, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03426/input.txt", "sample_output_relpath": "derived/input_output/data/p03426/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03426/Kotlin/s013606162.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s013606162", "user_id": "u139478771"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n abc089d()\n}\n\nfun abc089d() {\n val (h, w, d) = readLine()!!.split(' ').map { it.toInt() }\n val grid = (1..h).map { readLine()!!.split(' ').map { it.toInt() - 1 } }\n val q = readLine()!!.toInt()\n val queries = (1..q)\n .map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }\n\n val gridSize = h * w\n val numberToId = mutableMapOf>()\n val minCosts = Array(gridSize) { y -> IntArray(gridSize) { x -> if (y == x) 0 else Int.MAX_VALUE / 100 } }\n\n for (y in 0 until h) {\n for (x in 0 until w) {\n numberToId[grid[y][x]] = y to x\n }\n }\n\n for (i in 0 until gridSize - d) {\n var currNum = i\n while (currNum + d < gridSize) {\n val fromXy = numberToId[currNum] ?: error(\"なんで?\")\n val toXy = numberToId[currNum + d] ?: error(\"なんで?\")\n minCosts[i][currNum + d] = minCosts[i][currNum] +\n Math.abs(fromXy.first - toXy.first) + Math.abs(fromXy.second - toXy.second)\n currNum += d\n }\n }\n\n val answer = queries.map { minCosts[it.first][it.second] }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "sample_input": "3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03426", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1236, "cpu_time_ms": 1307, "memory_kb": 305684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s346253677", "group_id": "codeNet:p03426", "input_text": "fun main(args: Array) {\n abc089d()\n}\n\nfun abc089d() {\n val (h, w, d) = readLine()!!.split(' ').map { it.toInt() }\n val grid = (1..h).map { readLine()!!.split(' ').map { it.toInt() - 1 } }\n val q = readLine()!!.toInt()\n val queries = (1..q)\n .map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }\n\n val numberToId = mutableMapOf>()\n\n for (y in 0 until h) {\n for (x in 0 until w) {\n numberToId[grid[y][x]] = y to x\n }\n }\n\n val answer = queries.map {\n val (from, to) = it\n var currNum = from\n var sum = 0\n while (currNum != to) {\n val fromXy = numberToId[currNum] ?: error(\"なんで?\")\n val toXy = numberToId[currNum + d] ?: error(\"なんで?\")\n sum += Math.abs(fromXy.first - toXy.first) + Math.abs(fromXy.second - toXy.second)\n currNum += d\n }\n return@map sum\n }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1579842234, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03426/input.txt", "sample_output_relpath": "derived/input_output/data/p03426/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03426/Kotlin/s346253677.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s346253677", "user_id": "u139478771"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n abc089d()\n}\n\nfun abc089d() {\n val (h, w, d) = readLine()!!.split(' ').map { it.toInt() }\n val grid = (1..h).map { readLine()!!.split(' ').map { it.toInt() - 1 } }\n val q = readLine()!!.toInt()\n val queries = (1..q)\n .map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }\n\n val numberToId = mutableMapOf>()\n\n for (y in 0 until h) {\n for (x in 0 until w) {\n numberToId[grid[y][x]] = y to x\n }\n }\n\n val answer = queries.map {\n val (from, to) = it\n var currNum = from\n var sum = 0\n while (currNum != to) {\n val fromXy = numberToId[currNum] ?: error(\"なんで?\")\n val toXy = numberToId[currNum + d] ?: error(\"なんで?\")\n sum += Math.abs(fromXy.first - toXy.first) + Math.abs(fromXy.second - toXy.second)\n currNum += d\n }\n return@map sum\n }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "sample_input": "3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03426", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1031, "cpu_time_ms": 2111, "memory_kb": 145408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s547106094", "group_id": "codeNet:p03427", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val n = s.length\n\n if (s == s[0] + \"9\".repeat(n - 1)) {\n println(s[0] - '0' + 9 * (n - 1))\n } else {\n println(s[0] - '1' + 9 * (n - 1))\n }\n}", "language": "Kotlin", "metadata": {"date": 1585105075, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03427/input.txt", "sample_output_relpath": "derived/input_output/data/p03427/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03427/Kotlin/s547106094.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s547106094", "user_id": "u733811860"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val n = s.length\n\n if (s == s[0] + \"9\".repeat(n - 1)) {\n println(s[0] - '0' + 9 * (n - 1))\n } else {\n println(s[0] - '1' + 9 * (n - 1))\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "sample_input": "100\n"}, "reference_outputs": ["18\n"], "source_document_id": "p03427", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 214, "memory_kb": 33724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s961738195", "group_id": "codeNet:p03427", "input_text": "fun main(args : Array) {\n val n = readLine()!!\n\n if (n.toLong() < 10) {\n println(n)\n return\n }\n\n if (n.all { it == '9' }) {\n println(9 * n.length)\n return\n }\n\n if (n.takeLast(n.length-1).all { it == '9' }) {\n println(n[0].toString().toInt() + 9*(n.length-1))\n return\n }\n\n println(n[0].toString().toInt()-1 + 9*(n.length-1))\n}", "language": "Kotlin", "metadata": {"date": 1573819167, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03427/input.txt", "sample_output_relpath": "derived/input_output/data/p03427/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03427/Kotlin/s961738195.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s961738195", "user_id": "u262403099"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!\n\n if (n.toLong() < 10) {\n println(n)\n return\n }\n\n if (n.all { it == '9' }) {\n println(9 * n.length)\n return\n }\n\n if (n.takeLast(n.length-1).all { it == '9' }) {\n println(n[0].toString().toInt() + 9*(n.length-1))\n return\n }\n\n println(n[0].toString().toInt()-1 + 9*(n.length-1))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "sample_input": "100\n"}, "reference_outputs": ["18\n"], "source_document_id": "p03427", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 209, "memory_kb": 33460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s182025602", "group_id": "codeNet:p03434", "input_text": "fun main(args: Array) {\n val N = readLine()!!\n val As = readLine()!!.split(\" \").map(String::toInt).sortedDescending()\n\n val x = As.filterIndexed { i, x -> i%2==0 }.sum()\n val y = As.sum() - x\n println(x - y)\n}", "language": "Kotlin", "metadata": {"date": 1528082816, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03434.html", "problem_id": "p03434", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03434/input.txt", "sample_output_relpath": "derived/input_output/data/p03434/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03434/Kotlin/s182025602.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182025602", "user_id": "u185034753"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!\n val As = readLine()!!.split(\" \").map(String::toInt).sortedDescending()\n\n val x = As.filterIndexed { i, x -> i%2==0 }.sum()\n val y = As.sum() - x\n println(x - y)\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "sample_input": "2\n3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03434", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 238, "memory_kb": 37992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s244062548", "group_id": "codeNet:p03436", "input_text": "data class HWC(val h: Int, val w: Int, val c: Int) {\n constructor(hwc: List): this(hwc[0], hwc[1], hwc[2])\n}\nfun main(args: Array) {\n val dh = listOf(0, 1, 0, -1)\n val dw = listOf(1, 0, -1, 0)\n val (H, W) = listOfInt()\n var S = Array(H) { next().toCharArray() }\n val white = '.'; val black = '#'; val white2 = '@'\n var whiteCnt = S.sumBy { s -> s.count { it == white } }\n var goal = false\n val que = Queue()\n que.enqueue(HWC(0, 0, 1))\n while (!que.isEmpty()) {\n val p = que.dequeue()!!\n val h = p.h; val w = p.w; val c = p.c\n if (S[h][w] != white) continue\n if (h == H - 1 && w == W - 1) {\n goal = true\n whiteCnt -= c\n break\n }\n for (n in 0 until 4) {\n val nh = h + dh[n]; val nw = w + dw[n]\n if (nh < 0 || nw < 0 || nw > W - 1 || nh > H - 1) continue\n if (S[nh][nw] == white) {\n que.enqueue(HWC(nh, nw, c + 1))\n S[h][w] = white2\n }\n }\n }\n val ans = if (goal) whiteCnt else -1\n println(ans)\n}\nclass Queue {\n val elements = mutableListOf()\n fun isEmpty() = elements.isEmpty()\n fun enqueue(item: T) = elements.add(item)\n fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null\n}\n\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun nextInt(offset: Int = 0) = nextInt() + offset\nfun nextLong() = java.lang.Long.parseLong(next())\nfun nextLong(offset: Long = 0L) = nextLong() + offset\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n\n\n", "language": "Kotlin", "metadata": {"date": 1584634392, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03436/input.txt", "sample_output_relpath": "derived/input_output/data/p03436/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03436/Kotlin/s244062548.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244062548", "user_id": "u043150661"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "data class HWC(val h: Int, val w: Int, val c: Int) {\n constructor(hwc: List): this(hwc[0], hwc[1], hwc[2])\n}\nfun main(args: Array) {\n val dh = listOf(0, 1, 0, -1)\n val dw = listOf(1, 0, -1, 0)\n val (H, W) = listOfInt()\n var S = Array(H) { next().toCharArray() }\n val white = '.'; val black = '#'; val white2 = '@'\n var whiteCnt = S.sumBy { s -> s.count { it == white } }\n var goal = false\n val que = Queue()\n que.enqueue(HWC(0, 0, 1))\n while (!que.isEmpty()) {\n val p = que.dequeue()!!\n val h = p.h; val w = p.w; val c = p.c\n if (S[h][w] != white) continue\n if (h == H - 1 && w == W - 1) {\n goal = true\n whiteCnt -= c\n break\n }\n for (n in 0 until 4) {\n val nh = h + dh[n]; val nw = w + dw[n]\n if (nh < 0 || nw < 0 || nw > W - 1 || nh > H - 1) continue\n if (S[nh][nw] == white) {\n que.enqueue(HWC(nh, nw, c + 1))\n S[h][w] = white2\n }\n }\n }\n val ans = if (goal) whiteCnt else -1\n println(ans)\n}\nclass Queue {\n val elements = mutableListOf()\n fun isEmpty() = elements.isEmpty()\n fun enqueue(item: T) = elements.add(item)\n fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null\n}\n\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\nfun nextInt(offset: Int = 0) = nextInt() + offset\nfun nextLong() = java.lang.Long.parseLong(next())\nfun nextLong(offset: Long = 0L) = nextLong() + offset\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n\n\n", "problem_context": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "sample_input": "3 3\n..#\n#..\n...\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03436", "source_text": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1681, "cpu_time_ms": 251, "memory_kb": 37956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s357807176", "group_id": "codeNet:p03447", "input_text": "fun main(args:Array) {\n val (x,a,b) = (1..3).map { readLine()!!.toInt() }\n println( (x - a)%b )\n}", "language": "Kotlin", "metadata": {"date": 1523389768, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03447.html", "problem_id": "p03447", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03447/input.txt", "sample_output_relpath": "derived/input_output/data/p03447/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03447/Kotlin/s357807176.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357807176", "user_id": "u693048766"}, "prompt_components": {"gold_output": "84\n", "input_to_evaluate": "fun main(args:Array) {\n val (x,a,b) = (1..3).map { readLine()!!.toInt() }\n println( (x - a)%b )\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "sample_input": "1234\n150\n100\n"}, "reference_outputs": ["84\n"], "source_document_id": "p03447", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 107, "cpu_time_ms": 210, "memory_kb": 31740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s010437493", "group_id": "codeNet:p03456", "input_text": "fun main(args: Array) {\n val s = Math.sqrt(readLine()!!.replace(\" \", \"\").toDouble())\n println(if (Math.ceil(s) == Math.floor(s)) \"Yes\" else \"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1557892669, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Kotlin/s010437493.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s010437493", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = Math.sqrt(readLine()!!.replace(\" \", \"\").toDouble())\n println(if (Math.ceil(s) == Math.floor(s)) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 237, "memory_kb": 37936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s929555562", "group_id": "codeNet:p03456", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val n = br.readLine()!!.filterNot { it == ' ' }.toInt()\n var a = 1\n while (a * a <= n) {\n if (a * a == n ) {\n println(\"Yes\")\n return\n } else {\n a++\n }\n }\n println(\"No\")\n}\n\nfun err(print: Any) {\n System.err.println(print)\n}", "language": "Kotlin", "metadata": {"date": 1516587452, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Kotlin/s929555562.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929555562", "user_id": "u166163326"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val n = br.readLine()!!.filterNot { it == ' ' }.toInt()\n var a = 1\n while (a * a <= n) {\n if (a * a == n ) {\n println(\"Yes\")\n return\n } else {\n a++\n }\n }\n println(\"No\")\n}\n\nfun err(print: Any) {\n System.err.println(print)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 451, "cpu_time_ms": 196, "memory_kb": 29600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s843046806", "group_id": "codeNet:p03457", "input_text": "import java.io.InputStream\nimport java.io.PrintStream\nimport java.util.*\n\nclass Arc089A(\n val input: InputStream,\n val output: PrintStream\n) {\n data class Pos(val t: Int, val x: Int, val y: Int)\n\n /**\n * 指定した2つのポイント間で移動が可能か\n * 移動可能か?\n *\n * abs(x - x), abs(y - y) <= t\n * 偶数のときと奇数のときで移動できる座標に制約がある\n */\n fun calc(a: Pos, b: Pos): Boolean {\n // 移動距離が範囲内であれば基本的には問題ないが\n val dis = Math.abs(b.x - a.x) + Math.abs(b.y - a.y)\n val td = b.t - a.t\n if (dis > td) {\n return false\n }\n\n // 移動量が奇数の場合、同じ位置には戻ってこれない\n // もうちょっと一般化すると\n // x + y の偶数の場合、移動量が偶数なら x + y が偶数の位置にのみ移動できる\n // 奇数の場合も同様\n // x + y が偶数の場合、移動量が奇数なら x + y が奇数の位置にのみ移動できる\n if (dis % 2 != td % 2) {\n return false\n }\n\n return true\n }\n\n fun proc() {\n\n\n val sc = Scanner(input)\n val n = sc.nextInt()\n\n val posList = listOf(Pos(0, 0, 0)) +\n generateSequence {\n Pos(\n t = sc.nextInt(),\n x = sc.nextInt(),\n y = sc.nextInt()\n )\n }.take(n).toList()\n\n var i = 0\n while (i < posList.size - 1) {\n if (calc(posList[i], posList[i + 1])) {\n // ok\n } else {\n output.print(\"No\")\n return\n }\n ++i\n }\n output.print(\"Yes\")\n return\n }\n}\n\nfun main(args: Array) {\n Arc089A(System.`in`, System.out).proc()\n}\n", "language": "Kotlin", "metadata": {"date": 1542420027, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Kotlin/s843046806.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s843046806", "user_id": "u905389316"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.InputStream\nimport java.io.PrintStream\nimport java.util.*\n\nclass Arc089A(\n val input: InputStream,\n val output: PrintStream\n) {\n data class Pos(val t: Int, val x: Int, val y: Int)\n\n /**\n * 指定した2つのポイント間で移動が可能か\n * 移動可能か?\n *\n * abs(x - x), abs(y - y) <= t\n * 偶数のときと奇数のときで移動できる座標に制約がある\n */\n fun calc(a: Pos, b: Pos): Boolean {\n // 移動距離が範囲内であれば基本的には問題ないが\n val dis = Math.abs(b.x - a.x) + Math.abs(b.y - a.y)\n val td = b.t - a.t\n if (dis > td) {\n return false\n }\n\n // 移動量が奇数の場合、同じ位置には戻ってこれない\n // もうちょっと一般化すると\n // x + y の偶数の場合、移動量が偶数なら x + y が偶数の位置にのみ移動できる\n // 奇数の場合も同様\n // x + y が偶数の場合、移動量が奇数なら x + y が奇数の位置にのみ移動できる\n if (dis % 2 != td % 2) {\n return false\n }\n\n return true\n }\n\n fun proc() {\n\n\n val sc = Scanner(input)\n val n = sc.nextInt()\n\n val posList = listOf(Pos(0, 0, 0)) +\n generateSequence {\n Pos(\n t = sc.nextInt(),\n x = sc.nextInt(),\n y = sc.nextInt()\n )\n }.take(n).toList()\n\n var i = 0\n while (i < posList.size - 1) {\n if (calc(posList[i], posList[i + 1])) {\n // ok\n } else {\n output.print(\"No\")\n return\n }\n ++i\n }\n output.print(\"Yes\")\n return\n }\n}\n\nfun main(args: Array) {\n Arc089A(System.`in`, System.out).proc()\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1934, "cpu_time_ms": 704, "memory_kb": 100604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s593390852", "group_id": "codeNet:p03463", "input_text": "fun main(args: Array) = ripPro0408a()\n\nfun ripPro0408a() {\n val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }\n\n val answer = if ((a - b) % 2 == 0) \"Alice\" else \"Borys\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1586383611, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03463.html", "problem_id": "p03463", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03463/input.txt", "sample_output_relpath": "derived/input_output/data/p03463/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03463/Kotlin/s593390852.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593390852", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "fun main(args: Array) = ripPro0408a()\n\nfun ripPro0408a() {\n val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }\n\n val answer = if ((a - b) % 2 == 0) \"Alice\" else \"Borys\"\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA game is played on a strip consisting of N cells consecutively numbered from 1 to N.\n\nAlice has her token on cell A. Borys has his token on a different cell B.\n\nPlayers take turns, Alice moves first.\nThe moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1.\nNote that it's disallowed to move the token outside the strip or to the cell with the other player's token.\nIn one turn, the token of the moving player must be shifted exactly once.\n\nThe player who can't make a move loses, and the other player wins.\n\nBoth players want to win. Who wins if they play optimally?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint Alice if Alice wins, Borys if Borys wins, and Draw if nobody wins.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\nAlice\n\nAlice can move her token to cell 3.\nAfter that, Borys will be unable to move his token to cell 3, so he will have to move his token to cell 5.\nThen, Alice moves her token to cell 4. Borys can't make a move and loses.\n\nSample Input 2\n\n2 1 2\n\nSample Output 2\n\nBorys\n\nAlice can't make the very first move and loses.\n\nSample Input 3\n\n58 23 42\n\nSample Output 3\n\nBorys", "sample_input": "5 2 4\n"}, "reference_outputs": ["Alice\n"], "source_document_id": "p03463", "source_text": "Score : 300 points\n\nProblem Statement\n\nA game is played on a strip consisting of N cells consecutively numbered from 1 to N.\n\nAlice has her token on cell A. Borys has his token on a different cell B.\n\nPlayers take turns, Alice moves first.\nThe moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1.\nNote that it's disallowed to move the token outside the strip or to the cell with the other player's token.\nIn one turn, the token of the moving player must be shifted exactly once.\n\nThe player who can't make a move loses, and the other player wins.\n\nBoth players want to win. Who wins if they play optimally?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint Alice if Alice wins, Borys if Borys wins, and Draw if nobody wins.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\nAlice\n\nAlice can move her token to cell 3.\nAfter that, Borys will be unable to move his token to cell 3, so he will have to move his token to cell 5.\nThen, Alice moves her token to cell 4. Borys can't make a move and loses.\n\nSample Input 2\n\n2 1 2\n\nSample Output 2\n\nBorys\n\nAlice can't make the very first move and loses.\n\nSample Input 3\n\n58 23 42\n\nSample Output 3\n\nBorys", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 236, "memory_kb": 38184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s009173880", "group_id": "codeNet:p03464", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toInt() }\n var min = 2\n var max = 2\n for (i in N - 1 downTo 0) {\n var s = setOf(min, max)\n .filter { it >= A[i] }\n .map { (it..it + A[i] - 1).toList() }\n .flatten()\n .toSet()\n if (s.size == 0) {\n println(\"-1\")\n return\n }\n if (i > 0) {\n s = s.filter { it % A[i-1] == 0 }.toSet()\n }\n// println(s)\n min = s.min()!!\n max = s.max()!!\n }\n println(\"${min} ${max}\")\n}\n", "language": "Kotlin", "metadata": {"date": 1518583965, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03464.html", "problem_id": "p03464", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03464/input.txt", "sample_output_relpath": "derived/input_output/data/p03464/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03464/Kotlin/s009173880.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s009173880", "user_id": "u668726177"}, "prompt_components": {"gold_output": "6 8\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toInt()\n val A = readLine()!!.split(\" \").map { it.toInt() }\n var min = 2\n var max = 2\n for (i in N - 1 downTo 0) {\n var s = setOf(min, max)\n .filter { it >= A[i] }\n .map { (it..it + A[i] - 1).toList() }\n .flatten()\n .toSet()\n if (s.size == 0) {\n println(\"-1\")\n return\n }\n if (i > 0) {\n s = s.filter { it % A[i-1] == 0 }.toSet()\n }\n// println(s)\n min = s.min()!!\n max = s.max()!!\n }\n println(\"${min} ${max}\")\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "sample_input": "4\n3 4 3 2\n"}, "reference_outputs": ["6 8\n"], "source_document_id": "p03464", "source_text": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 634, "cpu_time_ms": 2119, "memory_kb": 228836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494180707", "group_id": "codeNet:p03464", "input_text": "import java.util.Scanner\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val k = scanner.nextInt()\n val a = Array(k, { 0 })\n for (i in (0..(k - 1))) {\n a[i] = scanner.nextInt()\n }\n if (a[k - 1] >= 3) {\n println(\"-1\")\n return\n }\n var ansMax: Long = 2\n var ansMin: Int = 2\n for (j in (1..k)) {\n val i = k - j\n ansMax += (a[i] - 1)\n if (j == k) {\n println(\"$ansMin $ansMax\")\n return\n }\n ansMax = ansMax / a[i - 1] * a[i - 1]\n ansMin = ((ansMin - 1) / a[i - 1] + 1) * a[i - 1]\n if (ansMin > ansMax) {\n println(\"-1\")\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1515984891, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03464.html", "problem_id": "p03464", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03464/input.txt", "sample_output_relpath": "derived/input_output/data/p03464/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03464/Kotlin/s494180707.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s494180707", "user_id": "u253759478"}, "prompt_components": {"gold_output": "6 8\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val k = scanner.nextInt()\n val a = Array(k, { 0 })\n for (i in (0..(k - 1))) {\n a[i] = scanner.nextInt()\n }\n if (a[k - 1] >= 3) {\n println(\"-1\")\n return\n }\n var ansMax: Long = 2\n var ansMin: Int = 2\n for (j in (1..k)) {\n val i = k - j\n ansMax += (a[i] - 1)\n if (j == k) {\n println(\"$ansMin $ansMax\")\n return\n }\n ansMax = ansMax / a[i - 1] * a[i - 1]\n ansMin = ((ansMin - 1) / a[i - 1] + 1) * a[i - 1]\n if (ansMin > ansMax) {\n println(\"-1\")\n return\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "sample_input": "4\n3 4 3 2\n"}, "reference_outputs": ["6 8\n"], "source_document_id": "p03464", "source_text": "Score : 500 points\n\nProblem Statement\n\nAn adult game master and N children are playing a game on an ice rink.\nThe game consists of K rounds.\nIn the i-th round, the game master announces:\n\nForm groups consisting of A_i children each!\n\nThen the children who are still in the game form as many groups of A_i children as possible.\nOne child may belong to at most one group.\nThose who are left without a group leave the game. The others proceed to the next round.\nNote that it's possible that nobody leaves the game in some round.\n\nIn the end, after the K-th round, there are exactly two children left, and they are declared the winners.\n\nYou have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.\n\nFind the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\n2 \\leq A_i \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA_1 A_2 ... A_K\n\nOutput\n\nPrint two integers representing the smallest and the largest possible value of N, respectively,\nor a single integer -1 if the described situation is impossible.\n\nSample Input 1\n\n4\n3 4 3 2\n\nSample Output 1\n\n6 8\n\nFor example, if the game starts with 6 children, then it proceeds as follows:\n\nIn the first round, 6 children form 2 groups of 3 children, and nobody leaves the game.\n\nIn the second round, 6 children form 1 group of 4 children, and 2 children leave the game.\n\nIn the third round, 4 children form 1 group of 3 children, and 1 child leaves the game.\n\nIn the fourth round, 3 children form 1 group of 2 children, and 1 child leaves the game.\n\nThe last 2 children are declared the winners.\n\nSample Input 2\n\n5\n3 4 100 3 2\n\nSample Output 2\n\n-1\n\nThis situation is impossible.\nIn particular, if the game starts with less than 100 children, everyone leaves after the third round.\n\nSample Input 3\n\n10\n2 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\n2 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 708, "cpu_time_ms": 526, "memory_kb": 53104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s314485098", "group_id": "codeNet:p03469", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(S: String){\n println(\"2018\" + S.slice(4 until S.length))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val S = sc.next()\n solve(S)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1564868690, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03469/input.txt", "sample_output_relpath": "derived/input_output/data/p03469/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03469/Kotlin/s314485098.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s314485098", "user_id": "u329232967"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(S: String){\n println(\"2018\" + S.slice(4 until S.length))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val S = sc.next()\n solve(S)\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "sample_input": "2017/01/07\n"}, "reference_outputs": ["2018/01/07\n"], "source_document_id": "p03469", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 695, "cpu_time_ms": 191, "memory_kb": 31400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s812434290", "group_id": "codeNet:p03470", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val mochi = mutableListOf()\n for(d in 1..n) {\n mochi.add(readLine()!!.toInt())\n }\n\n print(mochi.distinct().size)\n}\n", "language": "Kotlin", "metadata": {"date": 1595337030, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Kotlin/s812434290.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s812434290", "user_id": "u992618480"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val mochi = mutableListOf()\n for(d in 1..n) {\n mochi.add(readLine()!!.toInt())\n }\n\n print(mochi.distinct().size)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 112, "memory_kb": 36976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s079003827", "group_id": "codeNet:p03470", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val d = nextLongAry(n)\n println(d.distinct().size)\n\n\n}\n\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1589673710, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Kotlin/s079003827.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079003827", "user_id": "u581625805"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val d = nextLongAry(n)\n println(d.distinct().size)\n\n\n}\n\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 17548, "cpu_time_ms": 206, "memory_kb": 33964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s668953037", "group_id": "codeNet:p03470", "input_text": "import java.util.*\n\nfun main(args : Array) {\n println(inOutExec(Scanner(System.`in`)))\n}\n\nfun inOutExec(scanner: Scanner): String {\n val num = scanner.nextInt()\n val mochies: MutableSet = hashSetOf()\n repeat(num) {\n mochies.add(scanner.nextInt())\n }\n\n return mochies.size.toString()\n}", "language": "Kotlin", "metadata": {"date": 1545620582, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Kotlin/s668953037.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s668953037", "user_id": "u940096433"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*\n\nfun main(args : Array) {\n println(inOutExec(Scanner(System.`in`)))\n}\n\nfun inOutExec(scanner: Scanner): String {\n val num = scanner.nextInt()\n val mochies: MutableSet = hashSetOf()\n repeat(num) {\n mochies.add(scanner.nextInt())\n }\n\n return mochies.size.toString()\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 322, "cpu_time_ms": 223, "memory_kb": 35916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s738280363", "group_id": "codeNet:p03470", "input_text": "import java.io.InputStream\nimport java.io.PrintStream\nimport java.util.*\n\nclass Abc085B(\n val input: InputStream,\n val output: PrintStream\n) {\n fun proc() {\n val sc = Scanner(input)\n val n = sc.nextInt()\n val input = generateSequence { sc.nextInt() }\n .take(n).toList().distinct()\n output.print(input.size)\n }\n}\n\nfun main(args: Array) {\n Abc085B(System.`in`, System.out).proc()\n}\n", "language": "Kotlin", "metadata": {"date": 1542352917, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/Kotlin/s738280363.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s738280363", "user_id": "u905389316"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.InputStream\nimport java.io.PrintStream\nimport java.util.*\n\nclass Abc085B(\n val input: InputStream,\n val output: PrintStream\n) {\n fun proc() {\n val sc = Scanner(input)\n val n = sc.nextInt()\n val input = generateSequence { sc.nextInt() }\n .take(n).toList().distinct()\n output.print(input.size)\n }\n}\n\nfun main(args: Array) {\n Abc085B(System.`in`, System.out).proc()\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 442, "cpu_time_ms": 210, "memory_kb": 31904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s899505589", "group_id": "codeNet:p03473", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n println(24 + (24 - sc.nextInt()))\n}", "language": "Kotlin", "metadata": {"date": 1583292304, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03473/input.txt", "sample_output_relpath": "derived/input_output/data/p03473/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03473/Kotlin/s899505589.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899505589", "user_id": "u733811860"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n println(24 + (24 - sc.nextInt()))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "sample_input": "21\n"}, "reference_outputs": ["27\n"], "source_document_id": "p03473", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 125, "cpu_time_ms": 173, "memory_kb": 31264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s099380532", "group_id": "codeNet:p03477", "input_text": "fun main(args: Array) {\n var (a,b,c,d) = readLine()!!.split(\" \").map(String::toInt)\n if(a+b > c+ b) println(\"Left\")\n else if(a+b < c+ d) println(\"Right\")\n else println(\"Balanced\")\n}\n", "language": "Kotlin", "metadata": {"date": 1553529927, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Kotlin/s099380532.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s099380532", "user_id": "u399261731"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "fun main(args: Array) {\n var (a,b,c,d) = readLine()!!.split(\" \").map(String::toInt)\n if(a+b > c+ b) println(\"Left\")\n else if(a+b < c+ d) println(\"Right\")\n else println(\"Balanced\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 202, "cpu_time_ms": 241, "memory_kb": 37960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s738235678", "group_id": "codeNet:p03479", "input_text": "fun main(args: Array) {\n var (X, Y) = readLine()!!.split(\" \").map { it.toLong() }\n var cnt = 0\n while (X <= Y) {\n X *= 2\n cnt++\n }\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1518487632, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03479.html", "problem_id": "p03479", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03479/input.txt", "sample_output_relpath": "derived/input_output/data/p03479/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03479/Kotlin/s738235678.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s738235678", "user_id": "u668726177"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n var (X, Y) = readLine()!!.split(\" \").map { it.toLong() }\n var cnt = 0\n while (X <= Y) {\n X *= 2\n cnt++\n }\n println(cnt)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03479", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 184, "cpu_time_ms": 233, "memory_kb": 37900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s928378596", "group_id": "codeNet:p03481", "input_text": "\nfun main(args:Array) {\n val (x,y) = readLine()!!.split(\" \").map { it.toLong() }\n\n val list = mutableListOf(x)\n\n while (list.last() *2 <= y) {\n list.add(list.last()*2)\n }\n println(list.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1591668149, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03481.html", "problem_id": "p03481", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03481/input.txt", "sample_output_relpath": "derived/input_output/data/p03481/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03481/Kotlin/s928378596.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928378596", "user_id": "u269969976"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nfun main(args:Array) {\n val (x,y) = readLine()!!.split(\" \").map { it.toLong() }\n\n val list = mutableListOf(x)\n\n while (list.last() *2 <= y) {\n list.add(list.last()*2)\n }\n println(list.size)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03481", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 238, "memory_kb": 37900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s970057936", "group_id": "codeNet:p03485", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n println((a + b + 1) / 2)\n}\n", "language": "Kotlin", "metadata": {"date": 1571875596, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Kotlin/s970057936.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970057936", "user_id": "u979004569"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n println((a + b + 1) / 2)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 234, "memory_kb": 35992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s306865743", "group_id": "codeNet:p03485", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n // 回答をここに書く\n val (a,b) = listOfInt()\n val sum = a+b\n val r = if(sum%2 == 0) sum / 2 else sum / 2 +1\n println(r)\n}\n\n// 入力取得\nfun next() = br.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1552851107, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Kotlin/s306865743.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306865743", "user_id": "u375901682"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.*\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval pw = PrintWriter(System.out)\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n // 回答をここに書く\n val (a,b) = listOfInt()\n val sum = a+b\n val r = if(sum%2 == 0) sum / 2 else sum / 2 +1\n println(r)\n}\n\n// 入力取得\nfun next() = br.readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() =listOfString().map { it.toInt() }\nfun listOfLong() =listOfString().map { it.toLong() }\nfun listOfDouble() =listOfString().map { it.toDouble() }\n\n// 約数のList\nfun divisor(value : Long) : List {\n val max = Math.sqrt(value.toDouble()).toLong()\n return (1..max)\n .filter { value % it == 0L }\n .map { listOf(it, value / it) }\n .flatten()\n .sorted()\n}\n\n// 範囲内の素数を取得\n// fromだけ指定すると戻り値の個数で素数判定ができる\nfun prime(from : Long, to : Long = from) : List {\n return (from..to).filter { i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all { j -> i % j != 0L }\n }\n}\n\n// 素因数分解\nfun decom(value : Long) : List{\n if (value == 1L) return listOf(1)\n val max = Math.sqrt(value.toDouble()).toLong()\n return prime(2, max).filter { value % it == 0L }\n}\n\n// 最大公約数\nfun gcd(a : Long, b : Long) : Long {\n return if (a % b == 0L) b else gcd(b, a % b)\n}\n\n// 文字列を入れ替え\nfun swap(base : String, a : String, b : String) : String {\n return base.map {\n when (it) {\n a.toCharArray()[0] -> b\n b.toCharArray()[0] -> a\n else -> it.toString()\n }\n }.joinToString()\n}\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1959, "cpu_time_ms": 204, "memory_kb": 33864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s329341122", "group_id": "codeNet:p03486", "input_text": "fun main(args: Array) {\n\n val s = readLine()!!.toCharArray().sorted()\n val t = readLine()!!.toCharArray().sortedDescending()\n val sortedS = s.joinToString(separator = \"\")\n val sortedT = t.joinToString(separator = \"\")\n\n val result = if (sortedS < sortedT) \"Yes\" else \"No\"\n\n print(result)\n}", "language": "Kotlin", "metadata": {"date": 1591763783, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03486/input.txt", "sample_output_relpath": "derived/input_output/data/p03486/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03486/Kotlin/s329341122.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s329341122", "user_id": "u542748657"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n\n val s = readLine()!!.toCharArray().sorted()\n val t = readLine()!!.toCharArray().sortedDescending()\n val sortedS = s.joinToString(separator = \"\")\n val sortedT = t.joinToString(separator = \"\")\n\n val result = if (sortedS < sortedT) \"Yes\" else \"No\"\n\n print(result)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 227, "memory_kb": 35792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s756398217", "group_id": "codeNet:p03486", "input_text": "fun main(args: Array) {\n var (a,b) = (0..1).map{\n readLine()!!.toList().map(Char::toString)\n }\n if(a.sorted().joinToString(\"\")) {\n var (a,b) = (0..1).map{\n readLine()!!.toList().map(Char::toString)\n }\n if(a.sorted().joinToString(\"\")) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n\n br.readLine()\n\n fun HashMap.putOrUpdate(key: Int) {\n if(this.containsKey(key)) this.put(key, this.get(key)!!.plus(1))\n else this.put(key, 1)\n }\n\n val map = hashMapOf()\n br.readLine().split(\" \").map { it.toInt() }\n .forEach { map.putOrUpdate(it) }\n\n val ans = map.keys.fold(0L) { acc, k ->\n val v: Int = map.get(k)!!\n if(k > v) acc + v else acc + (v - k)\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1568668019, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Kotlin/s272491063.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s272491063", "user_id": "u217010036"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.InputStreamReader\nimport java.io.BufferedReader\nimport java.util.HashMap\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n\n br.readLine()\n\n fun HashMap.putOrUpdate(key: Int) {\n if(this.containsKey(key)) this.put(key, this.get(key)!!.plus(1))\n else this.put(key, 1)\n }\n\n val map = hashMapOf()\n br.readLine().split(\" \").map { it.toInt() }\n .forEach { map.putOrUpdate(it) }\n\n val ans = map.keys.fold(0L) { acc, k ->\n val v: Int = map.get(k)!!\n if(k > v) acc + v else acc + (v - k)\n }\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 570, "memory_kb": 61856}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s485448214", "group_id": "codeNet:p03487", "input_text": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n var x = readLine()!!.split(\" \").map(String::toLong)\n var dic :MutableMap = mutableMapOf()\n var cnt = 0L\n x.map{\n if(dic[it] == null) dic[it] = 0\n dic[it] = dic[it]!! + 1\n }\n dic.toList().sortedBy{it.first}.reversed().map{\n var (k,v) = it\n if(k>v) cnt += v\n else cnt += v-k\n }\n println(cnt)\n}\n", "language": "Kotlin", "metadata": {"date": 1553435816, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Kotlin/s485448214.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s485448214", "user_id": "u399261731"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n var N = readLine()!!.toInt()\n var x = readLine()!!.split(\" \").map(String::toLong)\n var dic :MutableMap = mutableMapOf()\n var cnt = 0L\n x.map{\n if(dic[it] == null) dic[it] = 0\n dic[it] = dic[it]!! + 1\n }\n dic.toList().sortedBy{it.first}.reversed().map{\n var (k,v) = it\n if(k>v) cnt += v\n else cnt += v-k\n }\n println(cnt)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 444, "cpu_time_ms": 996, "memory_kb": 96960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s905224915", "group_id": "codeNet:p03488", "input_text": "enum class DIR {\n left, right, up, down\n}\nfun main(arg: Array) {\n val S = next()\n val N = S.length\n val (X, Y) = listOfInt()\n val A = mutableListOf()\n var c = 0\n S.forEach { s ->\n when (s) {\n 'F' -> c += 1\n 'T' -> { A.add(c); c = 0 }\n }\n }\n if (c > 0) A.add(c)\n val OFFSET = 10000\n val dp = Array(2) { BooleanArray(20000) }\n dp[0][OFFSET] = true\n A.forEachIndexed { index, dis ->\n val p = mutableListOf()\n if (index % 2 == 0) { //x\n for (x in 0 until 2 * OFFSET) {\n if (dp[0][x]) p.addAll(listOf(x + dis, x - dis))\n }\n p.forEach { x -> dp[0][x] = true }\n//System.err.println(\"x ${dp[0].withIndex().filter { it.value }.map { it.index }.joinToString(\",\")}\" )\n } else { //y\n if (index == 1) p.addAll(listOf(OFFSET + dis, OFFSET - dis))\n else\n for (y in dis until 2 * OFFSET - dis) {\n if (dp[1][y]) p.addAll(listOf(y + dis, y - dis))\n }\n p.forEach { y -> dp[1][y] = true }\n//System.err.println(\"y ${dp[1].withIndex().filter { it.value }.map { it.index }.joinToString(\",\")}\" )\n }\n }\n val ans = if (dp[0][OFFSET + X] && dp[1][OFFSET + Y]) \"Yes\" else \"No\"\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "language": "Kotlin", "metadata": {"date": 1585252665, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03488.html", "problem_id": "p03488", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03488/input.txt", "sample_output_relpath": "derived/input_output/data/p03488/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03488/Kotlin/s905224915.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s905224915", "user_id": "u043150661"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "enum class DIR {\n left, right, up, down\n}\nfun main(arg: Array) {\n val S = next()\n val N = S.length\n val (X, Y) = listOfInt()\n val A = mutableListOf()\n var c = 0\n S.forEach { s ->\n when (s) {\n 'F' -> c += 1\n 'T' -> { A.add(c); c = 0 }\n }\n }\n if (c > 0) A.add(c)\n val OFFSET = 10000\n val dp = Array(2) { BooleanArray(20000) }\n dp[0][OFFSET] = true\n A.forEachIndexed { index, dis ->\n val p = mutableListOf()\n if (index % 2 == 0) { //x\n for (x in 0 until 2 * OFFSET) {\n if (dp[0][x]) p.addAll(listOf(x + dis, x - dis))\n }\n p.forEach { x -> dp[0][x] = true }\n//System.err.println(\"x ${dp[0].withIndex().filter { it.value }.map { it.index }.joinToString(\",\")}\" )\n } else { //y\n if (index == 1) p.addAll(listOf(OFFSET + dis, OFFSET - dis))\n else\n for (y in dis until 2 * OFFSET - dis) {\n if (dp[1][y]) p.addAll(listOf(y + dis, y - dis))\n }\n p.forEach { y -> dp[1][y] = true }\n//System.err.println(\"y ${dp[1].withIndex().filter { it.value }.map { it.index }.joinToString(\",\")}\" )\n }\n }\n val ans = if (dp[0][OFFSET + X] && dp[1][OFFSET + Y]) \"Yes\" else \"No\"\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { Integer.parseInt(it) }\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03488", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1472, "cpu_time_ms": 1015, "memory_kb": 120708}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s017728997", "group_id": "codeNet:p03488", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n val ds = s.split(\"T\").map { it.length }\n val dxs = ds.withIndex().filter { it.index % 2 == 0 }.map { it.value }\n val dys = ds.withIndex().filter { it.index % 2 == 1 }.map { it.value }\n val xSet = calculateSet(dxs)\n val ySet = calculateSet(dys)\n println(if (x in xSet && y in ySet) \"Yes\" else \"No\")\n}\n\nfun calculateSet(ds: List): Set {\n if (ds.isEmpty()) {\n return setOf(0)\n }\n return ds.slice(1 until ds.size).fold(setOf(ds[0]), { current_set, d ->\n current_set.toList().map { listOf(it - d, it + d) }.flatten().toSet()\n })\n}", "language": "Kotlin", "metadata": {"date": 1514859334, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03488.html", "problem_id": "p03488", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03488/input.txt", "sample_output_relpath": "derived/input_output/data/p03488/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03488/Kotlin/s017728997.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s017728997", "user_id": "u771276542"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n val (x, y) = readLine()!!.split(\" \").map(String::toInt)\n val ds = s.split(\"T\").map { it.length }\n val dxs = ds.withIndex().filter { it.index % 2 == 0 }.map { it.value }\n val dys = ds.withIndex().filter { it.index % 2 == 1 }.map { it.value }\n val xSet = calculateSet(dxs)\n val ySet = calculateSet(dys)\n println(if (x in xSet && y in ySet) \"Yes\" else \"No\")\n}\n\nfun calculateSet(ds: List): Set {\n if (ds.isEmpty()) {\n return setOf(0)\n }\n return ds.slice(1 until ds.size).fold(setOf(ds[0]), { current_set, d ->\n current_set.toList().map { listOf(it - d, it + d) }.flatten().toSet()\n })\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03488", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 697, "cpu_time_ms": 910, "memory_kb": 119408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s096694630", "group_id": "codeNet:p03494", "input_text": "fun main(args: Array) {\n readLine()!!\n val xs = readLine()!!.split(\" \").map(String::toInt)\n println(xs.map(::div2Count).min())\n}\n\nfun div2Count(n: Int): Int {\n var count = 0\n var nn = n\n\n while (nn % 2 == 0) {\n count++\n nn /= 2\n }\n return count\n}\n\n", "language": "Kotlin", "metadata": {"date": 1582611069, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/Kotlin/s096694630.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096694630", "user_id": "u861119357"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()!!\n val xs = readLine()!!.split(\" \").map(String::toInt)\n println(xs.map(::div2Count).min())\n}\n\nfun div2Count(n: Int): Int {\n var count = 0\n var nn = n\n\n while (nn % 2 == 0) {\n count++\n nn /= 2\n }\n return count\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 236, "memory_kb": 37868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s702037183", "group_id": "codeNet:p03494", "input_text": "fun main(args: Array) {\n\treadLine()\n\tval list = readLine()!!.split(\" \").map(String::toInt)\n\t\n\tvar num : Int\n\tvar count : Int\n\t\n\tvar result : Int = 0\n\t\n\tfor (i in 0..list.size - 1) {\n\t\tnum = list[i]\n\t\tcount = 0\n\t\tif ( num%2 != 1) {\n\t\t\tdo {\n\t\t\t\tnum = num / 2\n\t\t\t\tcount = count + 1\n\t } while (num%2 != 1)\n\t\t\t\n\t\t\tif (i == 0) {\n\t\t\t\tresult = count\n\t\t\t}\n\t\t\t\n\t\t\tif (result > count) {\n\t\t\t\tresult = count\n\t\t\t}\n\t\t\t\n\t\t} else {\n\t\t\tresult = 0\n\t\t\treturn println(\"${result}\")\n\t\t}\n\t}\n\t\n\tprintln(\"${result}\")\n\t\n}", "language": "Kotlin", "metadata": {"date": 1559522153, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/Kotlin/s702037183.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s702037183", "user_id": "u651257341"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n\treadLine()\n\tval list = readLine()!!.split(\" \").map(String::toInt)\n\t\n\tvar num : Int\n\tvar count : Int\n\t\n\tvar result : Int = 0\n\t\n\tfor (i in 0..list.size - 1) {\n\t\tnum = list[i]\n\t\tcount = 0\n\t\tif ( num%2 != 1) {\n\t\t\tdo {\n\t\t\t\tnum = num / 2\n\t\t\t\tcount = count + 1\n\t } while (num%2 != 1)\n\t\t\t\n\t\t\tif (i == 0) {\n\t\t\t\tresult = count\n\t\t\t}\n\t\t\t\n\t\t\tif (result > count) {\n\t\t\t\tresult = count\n\t\t\t}\n\t\t\t\n\t\t} else {\n\t\t\tresult = 0\n\t\t\treturn println(\"${result}\")\n\t\t}\n\t}\n\t\n\tprintln(\"${result}\")\n\t\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 509, "cpu_time_ms": 316, "memory_kb": 36156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s851108781", "group_id": "codeNet:p03495", "input_text": "import java.io.PrintWriter\nimport java.util.*\n\nval pw = PrintWriter(System.out)\n\nval NUM_MAX = 20 \nfun main(args: Array) {\n val (n, k) = readListOfInt()\n val a = readListOfInt()\n \n val numList = (0..NUM_MAX).map{ 0 }.toMutableList()\n\n for(i in 0 until n) {\n numList[a[i]]++\n }\n \n val filteredNumList = numList.filter { it > 0 }.sorted()\n\n val cnt = filteredNumList.slice(0 until (filteredNumList.size-k)).sum()\n\n println(cnt)\n\n pw.flush()\n}\n\nfun inputList() = \n readLine()!!.split(\" \").map(String::toInt)\n\nfun sum_digits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\n/****** Decrared Functions ******/\n\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\n\nfun println(value : Any) {\n pw.println(value)\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n if(b==0L) a else gcd(b, a % b)\n", "language": "Kotlin", "metadata": {"date": 1563290247, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03495.html", "problem_id": "p03495", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03495/input.txt", "sample_output_relpath": "derived/input_output/data/p03495/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03495/Kotlin/s851108781.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s851108781", "user_id": "u026686258"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\n\nval pw = PrintWriter(System.out)\n\nval NUM_MAX = 20 \nfun main(args: Array) {\n val (n, k) = readListOfInt()\n val a = readListOfInt()\n \n val numList = (0..NUM_MAX).map{ 0 }.toMutableList()\n\n for(i in 0 until n) {\n numList[a[i]]++\n }\n \n val filteredNumList = numList.filter { it > 0 }.sorted()\n\n val cnt = filteredNumList.slice(0 until (filteredNumList.size-k)).sum()\n\n println(cnt)\n\n pw.flush()\n}\n\nfun inputList() = \n readLine()!!.split(\" \").map(String::toInt)\n\nfun sum_digits(num_: Long): Long {\n var num = num_\n var rtn: Long = 0\n while(num != 0.toLong()) {\n val tmp = num % 10\n rtn += tmp\n num /= 10\n }\n return rtn\n}\n\n/****** Decrared Functions ******/\n\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\n\nfun println(value : Any) {\n pw.println(value)\n}\n\nfun gcd(a: Long, b: Long): Long = \n if(b != 0L) a else gcd(b, a % b)\n\nfun lcm(a: Long, b: Long) = \n if(b==0L) a else gcd(b, a % b)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03495", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1343, "cpu_time_ms": 658, "memory_kb": 82544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s145991157", "group_id": "codeNet:p03497", "input_text": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main(args: Array) {\n val (n, k) = intList()\n val a = intList()\n val group = a.groupBy { it }\n val groupSize = group.keys.size\n if (groupSize <= k) {\n println(\"0\")\n return\n }\n var remainGroupCount = groupSize - k\n var count = 0\n group.map { it.value.size }\n .sorted()\n .forEach {\n count += it\n remainGroupCount--\n if (remainGroupCount <= 0) {\n println(count.toString())\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1590802463, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03497.html", "problem_id": "p03497", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03497/input.txt", "sample_output_relpath": "derived/input_output/data/p03497/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03497/Kotlin/s145991157.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s145991157", "user_id": "u979429407"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun intList() = readLine()?.split(\" \")?.map(String::toInt) ?: TODO()\nfun main(args: Array) {\n val (n, k) = intList()\n val a = intList()\n val group = a.groupBy { it }\n val groupSize = group.keys.size\n if (groupSize <= k) {\n println(\"0\")\n return\n }\n var remainGroupCount = groupSize - k\n var count = 0\n group.map { it.value.size }\n .sorted()\n .forEach {\n count += it\n remainGroupCount--\n if (remainGroupCount <= 0) {\n println(count.toString())\n return\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03497", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 601, "cpu_time_ms": 948, "memory_kb": 111016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s177000267", "group_id": "codeNet:p03497", "input_text": "fun main(args: Array) = yorukatsu20c()\n\nfun yorukatsu20c() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toInt() }\n\n val answer = aList.asSequence()\n .groupBy { it }.map { it.value.size }.sortedDescending().drop(k).sum()\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1587432187, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03497.html", "problem_id": "p03497", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03497/input.txt", "sample_output_relpath": "derived/input_output/data/p03497/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03497/Kotlin/s177000267.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s177000267", "user_id": "u139478771"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu20c()\n\nfun yorukatsu20c() {\n val (n, k) = readLine()!!.split(' ').map { it.toInt() }\n val aList = readLine()!!.split(' ').map { it.toInt() }\n\n val answer = aList.asSequence()\n .groupBy { it }.map { it.value.size }.sortedDescending().drop(k).sum()\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03497", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 789, "memory_kb": 93180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s898817982", "group_id": "codeNet:p03498", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\n\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n// Global\n\nfun solve() {\n val n = nextLong()\n val a = longAry(n)\n var plus = false\n var minus = false\n for (i in 0 until n) {\n a[i] = nextLong()\n if(a[i] > 0L) plus = true\n if(a[i] < 0L) minus = true\n }\n\n val ansList: MutableList = mutableListOf()\n when {\n plus && !minus -> {\n val b = longAry(n)\n b[0] = a[0]\n var ans = 0L\n for (i in 0 until n - 1) {\n b[i + 1] = b[i] + a[i + 1]\n ans++\n ansList.add(\"${i + 1} ${i + 2}\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n }\n !plus && minus -> {\n val b = longAry(n)\n b[n - 1] = a[n - 1]\n var ans = 0L\n for (i in n - 1 downTo 1) {\n b[i - 1] = b[i] + a[i - 1]\n ans++\n ansList.add(\"${i + 1} $i\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n }\n plus && minus -> {\n var max = -INF\n var min = INF\n var maxIdx = 0L\n var minIdx = 0L\n for (i in 0 until n) {\n if(a[i] > max) {\n max = a[i]\n maxIdx = i\n }\n if(a[i] < min) {\n min = a[i]\n minIdx = i\n }\n }\n if(abs(max) >= abs(min)) {\n for (i in 0 until n) {\n if(i == maxIdx) continue\n a[i] += max\n ansList.add(\"${maxIdx + 1} ${i + 1}\")\n }\n ansList.add(\"${maxIdx + 1} ${maxIdx + 1}\")\n a[maxIdx] += max\n val b = longAry(n)\n b[0] = a[0]\n var ans = n\n for (i in 0 until n - 1) {\n b[i + 1] = b[i] + a[i + 1]\n ans++\n ansList.add(\"${i + 1} ${i + 2}\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n } else {\n for (i in 0 until n) {\n if(i == minIdx) continue\n a[i] += min\n ansList.add(\"${minIdx + 1} ${i + 1}\")\n }\n ansList.add(\"${minIdx + 1} ${minIdx + 1}\")\n a[minIdx] += min\n val b = longAry(n)\n b[n - 1] = a[n - 1]\n var ans = n\n for (i in n - 1 downTo 1) {\n b[i - 1] = b[i] + a[i - 1]\n ans++\n ansList.add(\"${i + 1} $i\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n }\n }\n else -> {\n println(0)\n }\n\n }\n\n\n\n\n}\n\n\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextLongs() = readLine()!!.split(\" \").map { it.toLong() }\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// String\n\nfun zAlgo(s: String): LongArray {\n val n = s.len\n val res = longAry(n)\n var i = 1L\n var j = 0L\n while(i < n) {\n while (i + j < n && s[j] == s[i + j]) j++\n res[i] = j\n if(j == 0L) {\n i++\n continue\n }\n var k = 1L\n while (i + k < n && k + res[k] < j) {\n res[i + k] = res[k]\n k++\n }\n i += k\n j -= k\n }\n\n return res\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "language": "Kotlin", "metadata": {"date": 1591011744, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03498.html", "problem_id": "p03498", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03498/input.txt", "sample_output_relpath": "derived/input_output/data/p03498/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03498/Kotlin/s898817982.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s898817982", "user_id": "u581625805"}, "prompt_components": {"gold_output": "2\n2 3\n3 3\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\n\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n// Global\n\nfun solve() {\n val n = nextLong()\n val a = longAry(n)\n var plus = false\n var minus = false\n for (i in 0 until n) {\n a[i] = nextLong()\n if(a[i] > 0L) plus = true\n if(a[i] < 0L) minus = true\n }\n\n val ansList: MutableList = mutableListOf()\n when {\n plus && !minus -> {\n val b = longAry(n)\n b[0] = a[0]\n var ans = 0L\n for (i in 0 until n - 1) {\n b[i + 1] = b[i] + a[i + 1]\n ans++\n ansList.add(\"${i + 1} ${i + 2}\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n }\n !plus && minus -> {\n val b = longAry(n)\n b[n - 1] = a[n - 1]\n var ans = 0L\n for (i in n - 1 downTo 1) {\n b[i - 1] = b[i] + a[i - 1]\n ans++\n ansList.add(\"${i + 1} $i\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n }\n plus && minus -> {\n var max = -INF\n var min = INF\n var maxIdx = 0L\n var minIdx = 0L\n for (i in 0 until n) {\n if(a[i] > max) {\n max = a[i]\n maxIdx = i\n }\n if(a[i] < min) {\n min = a[i]\n minIdx = i\n }\n }\n if(abs(max) >= abs(min)) {\n for (i in 0 until n) {\n if(i == maxIdx) continue\n a[i] += max\n ansList.add(\"${maxIdx + 1} ${i + 1}\")\n }\n ansList.add(\"${maxIdx + 1} ${maxIdx + 1}\")\n a[maxIdx] += max\n val b = longAry(n)\n b[0] = a[0]\n var ans = n\n for (i in 0 until n - 1) {\n b[i + 1] = b[i] + a[i + 1]\n ans++\n ansList.add(\"${i + 1} ${i + 2}\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n } else {\n for (i in 0 until n) {\n if(i == minIdx) continue\n a[i] += min\n ansList.add(\"${minIdx + 1} ${i + 1}\")\n }\n ansList.add(\"${minIdx + 1} ${minIdx + 1}\")\n a[minIdx] += min\n val b = longAry(n)\n b[n - 1] = a[n - 1]\n var ans = n\n for (i in n - 1 downTo 1) {\n b[i - 1] = b[i] + a[i - 1]\n ans++\n ansList.add(\"${i + 1} $i\")\n }\n println(ans)\n println(ansList.joinToString(\"\\n\"))\n }\n }\n else -> {\n println(0)\n }\n\n }\n\n\n\n\n}\n\n\n\n\n\n// Rule\n\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\n\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextLongs() = readLine()!!.split(\" \").map { it.toLong() }\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\n\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun nodeAry(n: Long) = Array(n.toInt()) { Node(it.toLong()) }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\n\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\n\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\n\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun erathos(n: Long): LongArray {\n val res = LongArray(n.toInt() + 1) { it.toLong() }\n for (i in 2..n) {\n if(i * i > n) break\n for (j in i * i..n step i) {\n if(res[j] == j) res[j] = i\n }\n }\n res[0] = -1L\n res[1] = -1L\n return res\n}\nfun modAdd(a: Long, b: Long) = if(a + b >= MOD) a + b - MOD else a + b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// String\n\nfun zAlgo(s: String): LongArray {\n val n = s.len\n val res = longAry(n)\n var i = 1L\n var j = 0L\n while(i < n) {\n while (i + j < n && s[j] == s[i + j]) j++\n res[i] = j\n if(j == 0L) {\n i++\n continue\n }\n var k = 1L\n while (i + k < n && k + res[k] < j) {\n res[i + k] = res[k]\n k++\n }\n i += k\n j -= k\n }\n\n return res\n}\n\n// Graph\n\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\n\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n private val diffWeight = longAry(size, 0L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n val r = root(par[x])\n diffWeight[x] += diffWeight[par[x]]\n par[x] = r\n par[x]\n }\n }\n fun weight(x: Long): Long {\n root(x)\n return diffWeight[x]\n }\n fun diff(x: Long, y: Long) = abs(weight(y) - weight(x))\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long, d: Long) {\n var w = d\n w += weight(x)\n w -= weight(y)\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n w = -w\n }\n size[a] += size[b]\n par[b] = a\n diffWeight[b] = w\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\nOperation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.\n\nHe would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.\nIt can be proved that such a sequence of operations always exists under the constraints in this problem.\n\nCondition: a_1 \\leq a_2 \\leq ... \\leq a_{N}\n\nConstraints\n\n2 \\leq N \\leq 50\n\n-10^{6} \\leq a_i \\leq 10^{6}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nLet m be the number of operations in your solution. In the first line, print m.\nIn the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.\nThe output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.\n\nSample Input 1\n\n3\n-2 5 -1\n\nSample Output 1\n\n2\n2 3\n3 3\n\nAfter the first operation, a = (-2,5,4).\n\nAfter the second operation, a = (-2,5,8), and the condition is now satisfied.\n\nSample Input 2\n\n2\n-1 -3\n\nSample Output 2\n\n1\n2 1\n\nAfter the first operation, a = (-4,-3) and the condition is now satisfied.\n\nSample Input 3\n\n5\n0 0 0 0 0\n\nSample Output 3\n\n0\n\nThe condition is satisfied already in the beginning.", "sample_input": "3\n-2 5 -1\n"}, "reference_outputs": ["2\n2 3\n3 3\n"], "source_document_id": "p03498", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\nOperation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.\n\nHe would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.\nIt can be proved that such a sequence of operations always exists under the constraints in this problem.\n\nCondition: a_1 \\leq a_2 \\leq ... \\leq a_{N}\n\nConstraints\n\n2 \\leq N \\leq 50\n\n-10^{6} \\leq a_i \\leq 10^{6}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nLet m be the number of operations in your solution. In the first line, print m.\nIn the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.\nThe output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.\n\nSample Input 1\n\n3\n-2 5 -1\n\nSample Output 1\n\n2\n2 3\n3 3\n\nAfter the first operation, a = (-2,5,4).\n\nAfter the second operation, a = (-2,5,8), and the condition is now satisfied.\n\nSample Input 2\n\n2\n-1 -3\n\nSample Output 2\n\n1\n2 1\n\nAfter the first operation, a = (-4,-3) and the condition is now satisfied.\n\nSample Input 3\n\n5\n0 0 0 0 0\n\nSample Output 3\n\n0\n\nThe condition is satisfied already in the beginning.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 20915, "cpu_time_ms": 191, "memory_kb": 31648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s316289005", "group_id": "codeNet:p03504", "input_text": "fun main(args: Array) {\n val (N, C) = readLine()!!.split(\" \").map { it.toInt() }\n val maxT = 100000 * 2 + 1\n val onAirTVCounts = IntArray(maxT + 1)\n onAirTVCounts.fill(0)\n val s = mutableListOf()\n val t = mutableListOf()\n val c = mutableListOf()\n\n\n (0 until N).forEach {\n val (si, ti, ci) = readLine()!!.split(\" \").map { it.toInt() }\n s.add(si)\n t.add(ti)\n c.add(ci)\n }\n\n (0 until C).forEach {ci ->\n (0 until N).forEach {i ->\n // Imos\n if (c[ci] == i) {\n onAirTVCounts[2 *s[i] - 1]++\n onAirTVCounts[2 * t[i]]--\n }\n }\n }\n\n\n\n (0 until maxT).forEach {\n onAirTVCounts[it+1] += onAirTVCounts[it]\n }\n println(onAirTVCounts.max()!!)\n}\n", "language": "Kotlin", "metadata": {"date": 1563512842, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03504.html", "problem_id": "p03504", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03504/input.txt", "sample_output_relpath": "derived/input_output/data/p03504/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03504/Kotlin/s316289005.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s316289005", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, C) = readLine()!!.split(\" \").map { it.toInt() }\n val maxT = 100000 * 2 + 1\n val onAirTVCounts = IntArray(maxT + 1)\n onAirTVCounts.fill(0)\n val s = mutableListOf()\n val t = mutableListOf()\n val c = mutableListOf()\n\n\n (0 until N).forEach {\n val (si, ti, ci) = readLine()!!.split(\" \").map { it.toInt() }\n s.add(si)\n t.add(ti)\n c.add(ci)\n }\n\n (0 until C).forEach {ci ->\n (0 until N).forEach {i ->\n // Imos\n if (c[ci] == i) {\n onAirTVCounts[2 *s[i] - 1]++\n onAirTVCounts[2 * t[i]]--\n }\n }\n }\n\n\n\n (0 until maxT).forEach {\n onAirTVCounts[it+1] += onAirTVCounts[it]\n }\n println(onAirTVCounts.max()!!)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino is planning to record N TV programs with recorders.\n\nThe TV can receive C channels numbered 1 through C.\n\nThe i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.\n\nHere, there will never be more than one program that are broadcast on the same channel at the same time.\n\nWhen the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).\n\nFind the minimum number of recorders required to record the channels so that all the N programs are completely recorded.\n\nConstraints\n\n1≤N≤10^5\n\n1≤C≤30\n\n1≤s_i) {\n println(if(solve(readLine()!!)) \"YES\" else \"NO\")\n}\n\nfun solve(s:String):Boolean {\n val target = \"AKIHABARA\"\n\n var idx = 0\n for(i in target.indices) {\n if(s[idx] != target[i]) {\n if(target[i] == 'A') {\n continue\n } else {\n return false\n }\n } else {\n idx++\n }\n if(idx > s.lastIndex) {\n return i >= target.lastIndex - 1\n }\n }\n return true\n}", "language": "Kotlin", "metadata": {"date": 1595594042, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03523.html", "problem_id": "p03523", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03523/input.txt", "sample_output_relpath": "derived/input_output/data/p03523/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03523/Kotlin/s472110289.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s472110289", "user_id": "u269969976"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(arr: Array) {\n println(if(solve(readLine()!!)) \"YES\" else \"NO\")\n}\n\nfun solve(s:String):Boolean {\n val target = \"AKIHABARA\"\n\n var idx = 0\n for(i in target.indices) {\n if(s[idx] != target[i]) {\n if(target[i] == 'A') {\n continue\n } else {\n return false\n }\n } else {\n idx++\n }\n if(idx > s.lastIndex) {\n return i >= target.lastIndex - 1\n }\n }\n return true\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S.\n\nTakahashi can insert the character A at any position in this string any number of times.\n\nCan he change S into AKIHABARA?\n\nConstraints\n\n1 \\leq |S| \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf it is possible to change S into AKIHABARA, print YES; otherwise, print NO.\n\nSample Input 1\n\nKIHBR\n\nSample Output 1\n\nYES\n\nInsert one A at each of the four positions: the beginning, immediately after H, immediately after B and the end.\n\nSample Input 2\n\nAKIBAHARA\n\nSample Output 2\n\nNO\n\nThe correct spell is AKIHABARA.\n\nSample Input 3\n\nAAKIAHBAARA\n\nSample Output 3\n\nNO", "sample_input": "KIHBR\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03523", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S.\n\nTakahashi can insert the character A at any position in this string any number of times.\n\nCan he change S into AKIHABARA?\n\nConstraints\n\n1 \\leq |S| \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf it is possible to change S into AKIHABARA, print YES; otherwise, print NO.\n\nSample Input 1\n\nKIHBR\n\nSample Output 1\n\nYES\n\nInsert one A at each of the four positions: the beginning, immediately after H, immediately after B and the end.\n\nSample Input 2\n\nAKIBAHARA\n\nSample Output 2\n\nNO\n\nThe correct spell is AKIHABARA.\n\nSample Input 3\n\nAAKIAHBAARA\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 106, "memory_kb": 35608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s392617108", "group_id": "codeNet:p03525", "input_text": "fun Int.bit(i: Int) = 1 shl i and this > 0\n\nfun main(A: Array) {\n val n = readLine()!!.toInt()\n if (n > 24) {\n println(0)\n return\n }\n\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val b = java.util.BitSet(25)\n b[0] = true\n b[24] = true\n\n (0 until (1 shl n)).asSequence().map { bit ->\n b.clear(1, 24)\n for (i in a.indices) {\n val j = if (bit.bit(i)) 24 - a[i] else a[i]\n if (b[j])\n return@map 0\n b[j] = true\n }\n\n (1..24).asSequence().filter { b.get(it) }\n .map { it - b.previousSetBit(it - 1) }\n .min() ?: 0\n }.max().let(::println)\n}\n", "language": "Kotlin", "metadata": {"date": 1585633252, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03525.html", "problem_id": "p03525", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03525/input.txt", "sample_output_relpath": "derived/input_output/data/p03525/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03525/Kotlin/s392617108.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s392617108", "user_id": "u059234158"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun Int.bit(i: Int) = 1 shl i and this > 0\n\nfun main(A: Array) {\n val n = readLine()!!.toInt()\n if (n > 24) {\n println(0)\n return\n }\n\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val b = java.util.BitSet(25)\n b[0] = true\n b[24] = true\n\n (0 until (1 shl n)).asSequence().map { bit ->\n b.clear(1, 24)\n for (i in a.indices) {\n val j = if (bit.bit(i)) 24 - a[i] else a[i]\n if (b[j])\n return@map 0\n b[j] = true\n }\n\n (1..24).asSequence().filter { b.get(it) }\n .map { it - b.previousSetBit(it - 1) }\n .min() ?: 0\n }.max().let(::println)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIn CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.\n\nTakahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours.\nThe time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours.\nHere, we are using 24-hour notation.\nThat is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example.\n\nThen, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours.\n\nFind the maximum possible value of s.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n0 \\leq D_i \\leq 12\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the maximum possible value of s.\n\nSample Input 1\n\n3\n7 12 8\n\nSample Output 1\n\n4\n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each person's city at the moment when it is 0 o'clock in Takahashi's city. In this case, the time gap between the second and third persons' cities is 4 hours.\n\nSample Input 2\n\n2\n11 11\n\nSample Output 2\n\n2\n\nSample Input 3\n\n1\n0\n\nSample Output 3\n\n0\n\nNote that Takahashi himself is also a participant.", "sample_input": "3\n7 12 8\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03525", "source_text": "Score : 500 points\n\nProblem Statement\n\nIn CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.\n\nTakahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours.\nThe time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours.\nHere, we are using 24-hour notation.\nThat is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example.\n\nThen, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours.\n\nFind the maximum possible value of s.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n0 \\leq D_i \\leq 12\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the maximum possible value of s.\n\nSample Input 1\n\n3\n7 12 8\n\nSample Output 1\n\n4\n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each person's city at the moment when it is 0 o'clock in Takahashi's city. In this case, the time gap between the second and third persons' cities is 4 hours.\n\nSample Input 2\n\n2\n11 11\n\nSample Output 2\n\n2\n\nSample Input 3\n\n1\n0\n\nSample Output 3\n\n0\n\nNote that Takahashi himself is also a participant.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 695, "cpu_time_ms": 1326, "memory_kb": 105556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s494736615", "group_id": "codeNet:p03543", "input_text": "fun main(args: Array) {\n val n = readLine()!!\n val result = when {\n n[0] == n[1] && n[1] == n[2] -> \"Yes\"\n n[1] == n[2] && n[2] == n[3] -> \"Yes\"\n else -> \"No\"\n }\n println(result)\n}", "language": "Kotlin", "metadata": {"date": 1579242275, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03543.html", "problem_id": "p03543", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03543/input.txt", "sample_output_relpath": "derived/input_output/data/p03543/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03543/Kotlin/s494736615.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494736615", "user_id": "u088342491"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!\n val result = when {\n n[0] == n[1] && n[1] == n[2] -> \"Yes\"\n n[1] == n[2] && n[2] == n[3] -> \"Yes\"\n else -> \"No\"\n }\n println(result)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "sample_input": "1118\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03543", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 200, "memory_kb": 31724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s908642388", "group_id": "codeNet:p03543", "input_text": "fun main(args: Array) {\n abc079a()\n}\n\nfun abc079a() {\n val n = readLine()!!.toCharArray()\n\n val answer = if (n.take(3).all { it == n[1] } || n.takeLast(3).all { it == n[1] }) \"Yes\" else \"No\"\n\n println(answer)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1569985303, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03543.html", "problem_id": "p03543", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03543/input.txt", "sample_output_relpath": "derived/input_output/data/p03543/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03543/Kotlin/s908642388.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908642388", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n abc079a()\n}\n\nfun abc079a() {\n val n = readLine()!!.toCharArray()\n\n val answer = if (n.take(3).all { it == n[1] } || n.takeLast(3).all { it == n[1] }) \"Yes\" else \"No\"\n\n println(answer)\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "sample_input": "1118\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03543", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 221, "memory_kb": 34112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s321225948", "group_id": "codeNet:p03546", "input_text": "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 h = sc.nextInt()\n val w = sc.nextInt()\n val c = Array(10) { Array(10) { sc.nextInt() } }\n val a = Array(h) { Array(w) { sc.nextInt() } }\n val wf = Array(10) { Array(10) { 1000000000 } }\n for (i in 0 until 10) {\n for (j in 0 until 10) {\n if (i != j) {\n wf[i][j] = c[i][j]\n }\n }\n }\n for (k in 0 until 10) {\n for (i in 0 until 10) {\n for (j in 0 until 10) {\n if (wf[i][j] > wf[i][k] + wf[k][j]) {\n wf[i][j] = wf[i][k] + wf[k][j]\n }\n }\n }\n }\n var ans = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n val v = a[i][j]\n if (v != -1 && v != 1) {\n ans += wf[v][1]\n }\n }\n }\n println(ans)\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}", "language": "Kotlin", "metadata": {"date": 1586481569, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03546.html", "problem_id": "p03546", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03546/input.txt", "sample_output_relpath": "derived/input_output/data/p03546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03546/Kotlin/s321225948.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s321225948", "user_id": "u190507186"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "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 h = sc.nextInt()\n val w = sc.nextInt()\n val c = Array(10) { Array(10) { sc.nextInt() } }\n val a = Array(h) { Array(w) { sc.nextInt() } }\n val wf = Array(10) { Array(10) { 1000000000 } }\n for (i in 0 until 10) {\n for (j in 0 until 10) {\n if (i != j) {\n wf[i][j] = c[i][j]\n }\n }\n }\n for (k in 0 until 10) {\n for (i in 0 until 10) {\n for (j in 0 until 10) {\n if (wf[i][j] > wf[i][k] + wf[k][j]) {\n wf[i][j] = wf[i][k] + wf[k][j]\n }\n }\n }\n }\n var ans = 0\n for (i in 0 until h) {\n for (j in 0 until w) {\n val v = a[i][j]\n if (v != -1 && v != 1) {\n ans += wf[v][1]\n }\n }\n }\n println(ans)\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}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "sample_input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03546", "source_text": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1630, "cpu_time_ms": 332, "memory_kb": 35792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s303857452", "group_id": "codeNet:p03547", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.next()\n val b = sc.next()\n println(when {\n a > b -> \">\"\n a < b -> \"<\"\n else -> \"=\"\n })\n}", "language": "Kotlin", "metadata": {"date": 1582996503, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03547.html", "problem_id": "p03547", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03547/input.txt", "sample_output_relpath": "derived/input_output/data/p03547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03547/Kotlin/s303857452.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s303857452", "user_id": "u733811860"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val a = sc.next()\n val b = sc.next()\n println(when {\n a > b -> \">\"\n a < b -> \"<\"\n else -> \"=\"\n })\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "sample_input": "A B\n"}, "reference_outputs": ["<\n"], "source_document_id": "p03547", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 173, "memory_kb": 31392}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s747619530", "group_id": "codeNet:p03556", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int){\n var ret = Math.sqrt(N.toDouble()).toInt() - 1\n while(ret*ret <= N){\n ret++\n }\n println((ret - 1)*(ret-1))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n solve(N)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1565123211, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03556/input.txt", "sample_output_relpath": "derived/input_output/data/p03556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03556/Kotlin/s747619530.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s747619530", "user_id": "u329232967"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(N: Int){\n var ret = Math.sqrt(N.toDouble()).toInt() - 1\n while(ret*ret <= N){\n ret++\n }\n println((ret - 1)*(ret-1))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val N = sc.next().toInt()\n solve(N)\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 778, "cpu_time_ms": 181, "memory_kb": 31400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s730927323", "group_id": "codeNet:p03556", "input_text": "fun main(args: Array) {\n var N = readLine()!!.toLong()\n for(i in N downTo 0){\n var j = i.toDouble()\n var sq = (Math.sqrt(j)).toLong()\n \n if(sq * sq == i){\n println(i)\n break\n }\n } \n} \n", "language": "Kotlin", "metadata": {"date": 1553003827, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03556/input.txt", "sample_output_relpath": "derived/input_output/data/p03556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03556/Kotlin/s730927323.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730927323", "user_id": "u399261731"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n var N = readLine()!!.toLong()\n for(i in N downTo 0){\n var j = i.toDouble()\n var sq = (Math.sqrt(j)).toLong()\n \n if(sq * sq == i){\n println(i)\n break\n }\n } \n} \n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 263, "cpu_time_ms": 204, "memory_kb": 33732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s048528249", "group_id": "codeNet:p03558", "input_text": "fun main(arg: Array) {\n val k = readLine()!!.toInt()\n val po: Array = Array(k) { null }\n po[1] = 1\n var searchSet = setOf(1)\n while (!searchSet.isEmpty()) {\n val newSet: MutableSet = mutableSetOf()\n searchSet.forEach {\n val next1 = (it * 10) % k\n val next2 = (it + 1) % k\n val nextPo1 = po[next1]\n val nextPo2 = po[next2]\n if (nextPo1 == null) {\n po[next1] = po[it]\n newSet.add(next1)\n } else if (nextPo1 > po[it]!!) {\n po[next1] = po[it]\n }\n if (nextPo2 == null) {\n po[next2] = po[it]!! + 1\n newSet.add(next2)\n } else if (nextPo2 > po[it]!! + 1) {\n po[next2] = po[it]!! + 1\n }\n }\n searchSet = newSet\n }\n println(po[0])\n}\n", "language": "Kotlin", "metadata": {"date": 1559260651, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03558.html", "problem_id": "p03558", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03558/input.txt", "sample_output_relpath": "derived/input_output/data/p03558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03558/Kotlin/s048528249.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s048528249", "user_id": "u880126159"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(arg: Array) {\n val k = readLine()!!.toInt()\n val po: Array = Array(k) { null }\n po[1] = 1\n var searchSet = setOf(1)\n while (!searchSet.isEmpty()) {\n val newSet: MutableSet = mutableSetOf()\n searchSet.forEach {\n val next1 = (it * 10) % k\n val next2 = (it + 1) % k\n val nextPo1 = po[next1]\n val nextPo2 = po[next2]\n if (nextPo1 == null) {\n po[next1] = po[it]\n newSet.add(next1)\n } else if (nextPo1 > po[it]!!) {\n po[next1] = po[it]\n }\n if (nextPo2 == null) {\n po[next2] = po[it]!! + 1\n newSet.add(next2)\n } else if (nextPo2 > po[it]!! + 1) {\n po[next2] = po[it]!! + 1\n }\n }\n searchSet = newSet\n }\n println(po[0])\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03558", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 890, "cpu_time_ms": 331, "memory_kb": 40576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s314967470", "group_id": "codeNet:p03563", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val r = sc.nextInt()\n val g = sc.nextInt()\n println(r + (g - r) * 2)\n}", "language": "Kotlin", "metadata": {"date": 1582999510, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03563/input.txt", "sample_output_relpath": "derived/input_output/data/p03563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03563/Kotlin/s314967470.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s314967470", "user_id": "u733811860"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val r = sc.nextInt()\n val g = sc.nextInt()\n println(r + (g - r) * 2)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "sample_input": "2002\n2017\n"}, "reference_outputs": ["2032\n"], "source_document_id": "p03563", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 166, "cpu_time_ms": 187, "memory_kb": 29344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s370129102", "group_id": "codeNet:p03563", "input_text": "fun main(args: Array) {\n val R = readLine()!!.toInt()\n val G = readLine()!!.toInt()\n\n println(2*G-R)\n}", "language": "Kotlin", "metadata": {"date": 1548640345, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03563/input.txt", "sample_output_relpath": "derived/input_output/data/p03563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03563/Kotlin/s370129102.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s370129102", "user_id": "u185034753"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "fun main(args: Array) {\n val R = readLine()!!.toInt()\n val G = readLine()!!.toInt()\n\n println(2*G-R)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "sample_input": "2002\n2017\n"}, "reference_outputs": ["2032\n"], "source_document_id": "p03563", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 205, "memory_kb": 29864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s465864536", "group_id": "codeNet:p03563", "input_text": "fun main(args:Array) {\n val (a,b) = (1..2).map { readLine()!!.toInt() }\n (2*b - a).run(::println)\n}", "language": "Kotlin", "metadata": {"date": 1528990148, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03563/input.txt", "sample_output_relpath": "derived/input_output/data/p03563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03563/Kotlin/s465864536.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465864536", "user_id": "u693048766"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "fun main(args:Array) {\n val (a,b) = (1..2).map { readLine()!!.toInt() }\n (2*b - a).run(::println)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "sample_input": "2002\n2017\n"}, "reference_outputs": ["2032\n"], "source_document_id": "p03563", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 211, "memory_kb": 33692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s826540394", "group_id": "codeNet:p03564", "input_text": "fun main() {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n\n var answer = 1\n\n for (i in 0 until n) {\n if (answer * 2 <= answer + k) {\n answer = answer * 2\n } else {\n answer += k\n }\n }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1599533589, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03564.html", "problem_id": "p03564", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03564/input.txt", "sample_output_relpath": "derived/input_output/data/p03564/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03564/Kotlin/s826540394.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826540394", "user_id": "u542748657"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main() {\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n\n var answer = 1\n\n for (i in 0 until n) {\n if (answer * 2 <= answer + k) {\n answer = answer * 2\n } else {\n answer += k\n }\n }\n\n println(answer)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "sample_input": "4\n3\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03564", "source_text": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 95, "memory_kb": 34552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s034328548", "group_id": "codeNet:p03564", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n println(problem076b(n, k))\n}\n\nfun problem076b(n: Int, k: Int): Int {\n var res = 1\n for (i in 0 until n) {\n if (res > k) {\n res += k\n } else {\n res *= 2\n }\n }\n return res\n}", "language": "Kotlin", "metadata": {"date": 1580700087, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03564.html", "problem_id": "p03564", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03564/input.txt", "sample_output_relpath": "derived/input_output/data/p03564/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03564/Kotlin/s034328548.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034328548", "user_id": "u073232808"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val k = sc.nextInt()\n println(problem076b(n, k))\n}\n\nfun problem076b(n: Int, k: Int): Int {\n var res = 1\n for (i in 0 until n) {\n if (res > k) {\n res += k\n } else {\n res *= 2\n }\n }\n return res\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "sample_input": "4\n3\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03564", "source_text": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 180, "memory_kb": 31384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s647036201", "group_id": "codeNet:p03569", "input_text": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val s = br.readLine()!!\n var l = 0\n var r = s.length - 1\n var ans = 0\n while (l < r) {\n val sl = s[l]\n val sr = s[r]\n if (sl == sr) {\n l++\n r--\n } else {\n when {\n sl == 'x' -> l++\n sr == 'x' -> r--\n else -> {\n out.println(-1)\n return\n }\n }\n ans++\n }\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "language": "Kotlin", "metadata": {"date": 1595661767, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03569.html", "problem_id": "p03569", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03569/input.txt", "sample_output_relpath": "derived/input_output/data/p03569/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03569/Kotlin/s647036201.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647036201", "user_id": "u784448849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport kotlin.math.max\n\nval br = BufferedReader(InputStreamReader(System.`in`))\nval out = PrintWriter(System.out)\n\nfun main() {\n br.use { out.use {\n solve()\n out.flush()\n } }\n}\n\nfun solve() {\n val s = br.readLine()!!\n var l = 0\n var r = s.length - 1\n var ans = 0\n while (l < r) {\n val sl = s[l]\n val sr = s[r]\n if (sl == sr) {\n l++\n r--\n } else {\n when {\n sl == 'x' -> l++\n sr == 'x' -> r--\n else -> {\n out.println(-1)\n return\n }\n }\n ans++\n }\n }\n out.println(ans)\n}\n\nfun readInteger() = Integer.parseInt(br.readLine())\nfun readLong() = java.lang.Long.parseLong(br.readLine())\nfun readStringList() = br.readLine()!!.split(' ')\nfun readIntegerList() = readStringList().map(Integer::parseInt)\nfun readLongList() = readStringList().map(java.lang.Long::parseLong)\nfun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a string s consisting of lowercase English letters.\nSnuke can perform the following operation repeatedly:\n\nInsert a letter x to any position in s of his choice, including the beginning and end of s.\n\nSnuke's objective is to turn s into a palindrome.\nDetermine whether the objective is achievable. If it is achievable, find the minimum number of operations required.\n\nNotes\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf the objective is achievable, print the number of operations required.\nIf it is not, print -1 instead.\n\nSample Input 1\n\nxabxa\n\nSample Output 1\n\n2\n\nOne solution is as follows (newly inserted x are shown in bold):\n\nxabxa → xaxbxa → xaxbxax\n\nSample Input 2\n\nab\n\nSample Output 2\n\n-1\n\nNo sequence of operations can turn s into a palindrome.\n\nSample Input 3\n\na\n\nSample Output 3\n\n0\n\ns is a palindrome already at the beginning.\n\nSample Input 4\n\noxxx\n\nSample Output 4\n\n3\n\nOne solution is as follows:\n\noxxx → xoxxx → xxoxxx → xxxoxxx", "sample_input": "xabxa\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03569", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a string s consisting of lowercase English letters.\nSnuke can perform the following operation repeatedly:\n\nInsert a letter x to any position in s of his choice, including the beginning and end of s.\n\nSnuke's objective is to turn s into a palindrome.\nDetermine whether the objective is achievable. If it is achievable, find the minimum number of operations required.\n\nNotes\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf the objective is achievable, print the number of operations required.\nIf it is not, print -1 instead.\n\nSample Input 1\n\nxabxa\n\nSample Output 1\n\n2\n\nOne solution is as follows (newly inserted x are shown in bold):\n\nxabxa → xaxbxa → xaxbxax\n\nSample Input 2\n\nab\n\nSample Output 2\n\n-1\n\nNo sequence of operations can turn s into a palindrome.\n\nSample Input 3\n\na\n\nSample Output 3\n\n0\n\ns is a palindrome already at the beginning.\n\nSample Input 4\n\noxxx\n\nSample Output 4\n\n3\n\nOne solution is as follows:\n\noxxx → xoxxx → xxoxxx → xxxoxxx", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1153, "cpu_time_ms": 114, "memory_kb": 35752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s127393066", "group_id": "codeNet:p03573", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(a xor b xor c)\n}", "language": "Kotlin", "metadata": {"date": 1541291063, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03573.html", "problem_id": "p03573", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03573/input.txt", "sample_output_relpath": "derived/input_output/data/p03573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03573/Kotlin/s127393066.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127393066", "user_id": "u367259152"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n\n println(a xor b xor c)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "sample_input": "5 7 5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03573", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 231, "memory_kb": 37928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s987090076", "group_id": "codeNet:p03576", "input_text": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val (n, k) = nextIntList()\n val point = longAry2(n, 2)\n repeat(n) {\n val (x, y) = nextLongList()\n point[it][0] = x\n point[it][1] = y\n }\n val x = longAry(n)\n val y = longAry(n)\n for (i in 0 until n) {\n x[i] = point[i][0]\n y[i] = point[i][1]\n }\n x.sort()\n y.sort()\n var ans = LINF\n for (a in 0 until n - 1) {\n val leftX = x[a]\n for (b in 0 until n - 1) {\n val leftY = y[b]\n for (c in a + 1 until n) {\n val rightX = x[c]\n for (d in b + 1 until n) {\n val rightY = y[d]\n var count = 0\n for (i in 0 until n) {\n val nowX = point[i][0]\n val nowY = point[i][1]\n if (nowX >= min(leftX, rightX) && nowX <= max(leftX, rightX) && nowY >= min(leftY, rightY) && nowY <= max(leftY,rightY)) count++\n }\n if (count >= k) {\n val area = abs(rightX - leftX) * abs(rightY - leftY)\n ans = min(ans, area)\n }\n }\n }\n }\n }\n\n println(ans)\n\n\n}\n\n\nfun println(v: String) {\n pw.println(v)\n}\n\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \").toMutableList()\nfun nextIntList(index: Int = 0) = next().split(\" \").map { it.toInt() + index }.toMutableList()\nfun nextLongList(index: Long = 0L) = next().split(\" \").map { it.toLong() + index }.toMutableList()\nfun nextDoubleList() = next().split(\" \").map { it.toDouble() }.toMutableList()\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =\n listOf(a, b, c, d, e).max()!!.toLong()\n\nfun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =\n listOf(a, b, c, d, e).min()!!.toLong()\n\nfun gcd(a: Long, b: Long): Long = if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b", "language": "Kotlin", "metadata": {"date": 1585970263, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03576.html", "problem_id": "p03576", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03576/input.txt", "sample_output_relpath": "derived/input_output/data/p03576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03576/Kotlin/s987090076.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s987090076", "user_id": "u581625805"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val (n, k) = nextIntList()\n val point = longAry2(n, 2)\n repeat(n) {\n val (x, y) = nextLongList()\n point[it][0] = x\n point[it][1] = y\n }\n val x = longAry(n)\n val y = longAry(n)\n for (i in 0 until n) {\n x[i] = point[i][0]\n y[i] = point[i][1]\n }\n x.sort()\n y.sort()\n var ans = LINF\n for (a in 0 until n - 1) {\n val leftX = x[a]\n for (b in 0 until n - 1) {\n val leftY = y[b]\n for (c in a + 1 until n) {\n val rightX = x[c]\n for (d in b + 1 until n) {\n val rightY = y[d]\n var count = 0\n for (i in 0 until n) {\n val nowX = point[i][0]\n val nowY = point[i][1]\n if (nowX >= min(leftX, rightX) && nowX <= max(leftX, rightX) && nowY >= min(leftY, rightY) && nowY <= max(leftY,rightY)) count++\n }\n if (count >= k) {\n val area = abs(rightX - leftX) * abs(rightY - leftY)\n ans = min(ans, area)\n }\n }\n }\n }\n }\n\n println(ans)\n\n\n}\n\n\nfun println(v: String) {\n pw.println(v)\n}\n\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \").toMutableList()\nfun nextIntList(index: Int = 0) = next().split(\" \").map { it.toInt() + index }.toMutableList()\nfun nextLongList(index: Long = 0L) = next().split(\" \").map { it.toLong() + index }.toMutableList()\nfun nextDoubleList() = next().split(\" \").map { it.toDouble() }.toMutableList()\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =\n listOf(a, b, c, d, e).max()!!.toLong()\n\nfun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =\n listOf(a, b, c, d, e).min()!!.toLong()\n\nfun gcd(a: Long, b: Long): Long = if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N points in a two-dimensional plane.\n\nThe coordinates of the i-th point (1 \\leq i \\leq N) are (x_i,y_i).\n\nLet us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.\n\nHere, points on the sides of the rectangle are considered to be in the interior.\n\nFind the minimum possible area of such a rectangle.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 50\n\n-10^9 \\leq x_i,y_i \\leq 10^9 (1 \\leq i \\leq N)\n\nx_i≠x_j (1 \\leq i()\n for (i in 0 until N) {\n dm[D[i]] = (dm[D[i]] ?: 0) + 1\n }\n val tm = mutableMapOf()\n for (i in 0 until M) {\n tm[T[i]] = (tm[T[i]] ?: 0) + 1\n }\n\n for (t in tm) {\n val k = t.key\n if (dm.containsKey(k) && t.value <= dm[k]!!) continue\n println(\"NO\")\n return\n }\n\n println(\"YES\")\n}\n\n\n//val rd = debug.Reader(\"etc\", \"code-festival-2017-qualb\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1598885912, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03578.html", "problem_id": "p03578", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03578/input.txt", "sample_output_relpath": "derived/input_output/data/p03578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03578/Kotlin/s169345111.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s169345111", "user_id": "u404244809"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun solve() {\n val N = rd.readInt()\n val D = rd.readIntArray()\n val M = rd.readInt()\n val T = rd.readIntArray()\n\n val dm = mutableMapOf()\n for (i in 0 until N) {\n dm[D[i]] = (dm[D[i]] ?: 0) + 1\n }\n val tm = mutableMapOf()\n for (i in 0 until M) {\n tm[T[i]] = (tm[T[i]] ?: 0) + 1\n }\n\n for (t in tm) {\n val k = t.key\n if (dm.containsKey(k) && t.value <= dm[k]!!) continue\n println(\"NO\")\n return\n }\n\n println(\"YES\")\n}\n\n\n//val rd = debug.Reader(\"etc\", \"code-festival-2017-qualb\", \"b\", \"sample-1\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readListIntCol: (Int) -> List = { N -> (0 until N).map { readInt() } }\n val readListLongCol: (Int) -> List = { N -> (0 until N).map { readLong() } }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "sample_input": "5\n3 1 4 1 5\n3\n5 4 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03578", "source_text": "Score : 200 points\n\nProblem Statement\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.\n\nDetermine whether Rng can complete the problem set without creating new candidates of problems.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq M \\leq 200,000\n\n1 \\leq T_i \\leq 10^9\n\nAll numbers in the input are integers.\n\nPartial Score\n\n100 points will be awarded for passing the test set satisfying N \\leq 100 and M \\leq 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\nM\nT_1 T_2 ... T_M\n\nOutput\n\nPrint YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.\n\nSample Input 1\n\n5\n3 1 4 1 5\n3\n5 4 3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n\nSample Output 2\n\nNO\n\nNot enough 1600s.\n\nSample Input 3\n\n1\n800\n5\n100 100 100 100 100\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n\nSample Output 4\n\nYES", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2605, "cpu_time_ms": 797, "memory_kb": 102924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s456819568", "group_id": "codeNet:p03597", "input_text": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val a= readLine()!!.toInt()\n println(n*n-a)\n}", "language": "Kotlin", "metadata": {"date": 1542243083, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03597.html", "problem_id": "p03597", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03597/input.txt", "sample_output_relpath": "derived/input_output/data/p03597/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03597/Kotlin/s456819568.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s456819568", "user_id": "u914096045"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val n= readLine()!!.toInt()\n val a= readLine()!!.toInt()\n println(n*n-a)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have an N \\times N square grid.\n\nWe will paint each square in the grid either black or white.\n\nIf we paint exactly A squares white, how many squares will be painted black?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq A \\leq N^2\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutputs\n\nPrint the number of squares that will be painted black.\n\nSample Input 1\n\n3\n4\n\nSample Output 1\n\n5\n\nThere are nine squares in a 3 \\times 3 square grid.\nFour of them will be painted white, so the remaining five squares will be painted black.\n\nSample Input 2\n\n19\n100\n\nSample Output 2\n\n261\n\nSample Input 3\n\n10\n0\n\nSample Output 3\n\n100\n\nAs zero squares will be painted white, all the squares will be painted black.", "sample_input": "3\n4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03597", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have an N \\times N square grid.\n\nWe will paint each square in the grid either black or white.\n\nIf we paint exactly A squares white, how many squares will be painted black?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq A \\leq N^2\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutputs\n\nPrint the number of squares that will be painted black.\n\nSample Input 1\n\n3\n4\n\nSample Output 1\n\n5\n\nThere are nine squares in a 3 \\times 3 square grid.\nFour of them will be painted white, so the remaining five squares will be painted black.\n\nSample Input 2\n\n19\n100\n\nSample Output 2\n\n261\n\nSample Input 3\n\n10\n0\n\nSample Output 3\n\n100\n\nAs zero squares will be painted white, all the squares will be painted black.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 116, "cpu_time_ms": 209, "memory_kb": 33636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s582366969", "group_id": "codeNet:p03599", "input_text": "import java.lang.Math.min\n\nfun main(args: Array) = yorukatsu22e()\n\nfun yorukatsu22e() {\n operator fun List.component6() = this[5]\n val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }\n\n val sugarSet = mutableSetOf()\n for (cw in 0..f step c) for (dw in 0..f step d) sugarSet.add(cw + dw)\n val sugarPatterns = sugarSet.sorted().toIntArray()\n\n fun upperBound(list: IntArray, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] > key) ok = mid else ng = mid\n }\n return ok\n }\n\n var pair = a * 100 to 0\n var maxPercentage = 0.0\n\n for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {\n val waterWeight = aw + bw\n val maxOfSugarWeight = min(e * waterWeight / 100, f - waterWeight)\n if (maxOfSugarWeight < 0) continue\n\n val ub = upperBound(sugarPatterns, maxOfSugarWeight) - 1\n if (ub !in sugarPatterns.indices) continue\n\n val sugarWeight = sugarPatterns[ub]\n val sumWeight = sugarWeight + waterWeight\n\n val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()\n\n if (percentage > maxPercentage) {\n maxPercentage = percentage\n pair = sumWeight to sugarWeight\n }\n }\n\n val answer = \"${pair.first} ${pair.second}\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1587622638, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Kotlin/s582366969.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s582366969", "user_id": "u139478771"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "import java.lang.Math.min\n\nfun main(args: Array) = yorukatsu22e()\n\nfun yorukatsu22e() {\n operator fun List.component6() = this[5]\n val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }\n\n val sugarSet = mutableSetOf()\n for (cw in 0..f step c) for (dw in 0..f step d) sugarSet.add(cw + dw)\n val sugarPatterns = sugarSet.sorted().toIntArray()\n\n fun upperBound(list: IntArray, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] > key) ok = mid else ng = mid\n }\n return ok\n }\n\n var pair = a * 100 to 0\n var maxPercentage = 0.0\n\n for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {\n val waterWeight = aw + bw\n val maxOfSugarWeight = min(e * waterWeight / 100, f - waterWeight)\n if (maxOfSugarWeight < 0) continue\n\n val ub = upperBound(sugarPatterns, maxOfSugarWeight) - 1\n if (ub !in sugarPatterns.indices) continue\n\n val sugarWeight = sugarPatterns[ub]\n val sumWeight = sugarWeight + waterWeight\n\n val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()\n\n if (percentage > maxPercentage) {\n maxPercentage = percentage\n pair = sumWeight to sugarWeight\n }\n }\n\n val answer = \"${pair.first} ${pair.second}\"\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1424, "cpu_time_ms": 304, "memory_kb": 40460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s585712455", "group_id": "codeNet:p03599", "input_text": "fun main(args: Array) = yorukatsu22e()\n\nfun yorukatsu22e() {\n operator fun List.component6() = this[5]\n val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }\n\n val sugarSet = mutableSetOf()\n for (cw in 0..f step c) for (dw in 0..f step d) sugarSet.add(cw + dw)\n\n val sugarPatterns = sugarSet.sorted().toIntArray()\n\n fun upperBound(list: IntArray, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] > key) ok = mid else ng = mid\n }\n return ok\n }\n\n\n var pair = a * 100 to 0\n var maxPercentage = 0.0\n\n for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {\n val waterWeight = aw + bw\n val maxOfSugarWeight = Math.min(e * waterWeight / 100, f - waterWeight)\n if (maxOfSugarWeight < 0) continue\n\n val ub = upperBound(sugarPatterns, maxOfSugarWeight) - 1\n if (ub !in sugarPatterns.indices) continue\n\n val sugarWeight = sugarPatterns[ub]\n val sumWeight = sugarWeight + waterWeight\n\n val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()\n\n if (percentage > maxPercentage) {\n maxPercentage = percentage\n pair = sumWeight to sugarWeight\n }\n }\n\n val answer = \"${pair.first} ${pair.second}\"\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1587622079, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Kotlin/s585712455.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s585712455", "user_id": "u139478771"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "fun main(args: Array) = yorukatsu22e()\n\nfun yorukatsu22e() {\n operator fun List.component6() = this[5]\n val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }\n\n val sugarSet = mutableSetOf()\n for (cw in 0..f step c) for (dw in 0..f step d) sugarSet.add(cw + dw)\n\n val sugarPatterns = sugarSet.sorted().toIntArray()\n\n fun upperBound(list: IntArray, key: Int): Int {\n var ng = -1\n var ok = list.size\n\n while (ok - ng > 1) {\n val mid = (ok + ng) / 2\n if (list[mid] > key) ok = mid else ng = mid\n }\n return ok\n }\n\n\n var pair = a * 100 to 0\n var maxPercentage = 0.0\n\n for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {\n val waterWeight = aw + bw\n val maxOfSugarWeight = Math.min(e * waterWeight / 100, f - waterWeight)\n if (maxOfSugarWeight < 0) continue\n\n val ub = upperBound(sugarPatterns, maxOfSugarWeight) - 1\n if (ub !in sugarPatterns.indices) continue\n\n val sugarWeight = sugarPatterns[ub]\n val sumWeight = sugarWeight + waterWeight\n\n val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()\n\n if (percentage > maxPercentage) {\n maxPercentage = percentage\n pair = sumWeight to sugarWeight\n }\n }\n\n val answer = \"${pair.first} ${pair.second}\"\n\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1404, "cpu_time_ms": 302, "memory_kb": 40656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s245741777", "group_id": "codeNet:p03599", "input_text": "fun main(args: Array) {\n val input = readLine()!!.split(\" \")\n\n val a = input[0].toDouble()\n val b = input[1].toDouble()\n val C = input[2].toDouble()\n val D = input[3].toDouble()\n val E = input[4].toDouble()\n val F = input[5].toDouble()\n\n val base: Double = E/100.0\n val A: Double = a*100.0\n val B: Double = b*100.0\n\n val ac: Double = base - C/A\n val ad: Double = base - D/A\n val bc: Double = base - C/B\n val bd: Double = base - D/B\n\n val Dac = WaterData(\n A,C,ac\n )\n\n val Dad = WaterData(\n A,D,ad\n )\n\n val Dbc = WaterData(\n B,C,bc\n )\n\n val Dbd = WaterData(\n B,D,bd\n )\n val list = mutableListOf(Dac,Dad,Dbc,Dbd).filter{\n it.rate >= 0\n }.sortedBy{it.rate}\n\n list.map{\n if(it.water + it.sugar <= F) {\n println(\"${it.water+it.sugar} ${it.sugar}\")\n return\n }\n }\n}\n\nprivate data class WaterData(\n val water: Double,\n val sugar: Double,\n val rate: Double\n)\n{}", "language": "Kotlin", "metadata": {"date": 1562336237, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Kotlin/s245741777.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s245741777", "user_id": "u169088512"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()!!.split(\" \")\n\n val a = input[0].toDouble()\n val b = input[1].toDouble()\n val C = input[2].toDouble()\n val D = input[3].toDouble()\n val E = input[4].toDouble()\n val F = input[5].toDouble()\n\n val base: Double = E/100.0\n val A: Double = a*100.0\n val B: Double = b*100.0\n\n val ac: Double = base - C/A\n val ad: Double = base - D/A\n val bc: Double = base - C/B\n val bd: Double = base - D/B\n\n val Dac = WaterData(\n A,C,ac\n )\n\n val Dad = WaterData(\n A,D,ad\n )\n\n val Dbc = WaterData(\n B,C,bc\n )\n\n val Dbd = WaterData(\n B,D,bd\n )\n val list = mutableListOf(Dac,Dad,Dbc,Dbd).filter{\n it.rate >= 0\n }.sortedBy{it.rate}\n\n list.map{\n if(it.water + it.sugar <= F) {\n println(\"${it.water+it.sugar} ${it.sugar}\")\n return\n }\n }\n}\n\nprivate data class WaterData(\n val water: Double,\n val sugar: Double,\n val rate: Double\n)\n{}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 924, "cpu_time_ms": 239, "memory_kb": 37992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s969346634", "group_id": "codeNet:p03599", "input_text": "fun main(args:Array) {\n\tval x = readLine()!!.split(\" \").map {it.toInt()}\n\tval a=x[0]\n\tval b=x[1]\n\tval c=x[2]\n\tval d=x[3]\n\tval e=x[4]\n\tval f=x[5]\n\t\n\tval water = (0..30).map { i ->\n\t\t(0..30).map { j-> 100*a*i + 100*b*j }\n\t}.flatten().distinct().filter { it<=f }.sorted()\n\t\n\tval sugar = (0..1+e*f/100).map { i ->\n\t\t(0..1+e*f/100).map { j-> c*i + d*j }\n\t}.flatten().distinct().sorted()\n\t\n\tvar maxw = 0\n\tvar maxs = 0\n\tvar maxd=0.0\n\twater.forEach { w->\n\t\tsugar.forEach{ s->\n\t\t\tval d=s/(w+s).toDouble()\n\t\t\tif(d>maxd && w+s=s){\n\t\t\t\tmaxw=w\n\t\t\t\tmaxs=s\n\t\t\t\tmaxd=d\n\t\t\t}\n\t\t}\n\t}\n\tprintln(\"${maxw+maxs} $maxs\")\n\t\n}", "language": "Kotlin", "metadata": {"date": 1542340020, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Kotlin/s969346634.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s969346634", "user_id": "u914096045"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "fun main(args:Array) {\n\tval x = readLine()!!.split(\" \").map {it.toInt()}\n\tval a=x[0]\n\tval b=x[1]\n\tval c=x[2]\n\tval d=x[3]\n\tval e=x[4]\n\tval f=x[5]\n\t\n\tval water = (0..30).map { i ->\n\t\t(0..30).map { j-> 100*a*i + 100*b*j }\n\t}.flatten().distinct().filter { it<=f }.sorted()\n\t\n\tval sugar = (0..1+e*f/100).map { i ->\n\t\t(0..1+e*f/100).map { j-> c*i + d*j }\n\t}.flatten().distinct().sorted()\n\t\n\tvar maxw = 0\n\tvar maxs = 0\n\tvar maxd=0.0\n\twater.forEach { w->\n\t\tsugar.forEach{ s->\n\t\t\tval d=s/(w+s).toDouble()\n\t\t\tif(d>maxd && w+s=s){\n\t\t\t\tmaxw=w\n\t\t\t\tmaxs=s\n\t\t\t\tmaxd=d\n\t\t\t}\n\t\t}\n\t}\n\tprintln(\"${maxw+maxs} $maxs\")\n\t\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 621, "cpu_time_ms": 3163, "memory_kb": 287960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s495145159", "group_id": "codeNet:p03600", "input_text": "fun main(arg: Array) {\n val N = nextInt()\n val A = Array(N) { listOfInt() }\n val R = Array(N) { BooleanArray(N) }\n for (k in 0 until N)\n for (h in 0 until N) for (w in 0 until N) {\n if (A[h][w] > A[h][k] + A[k][w]) {\n return println(-1)\n }\n if (A[h][w] == A[h][k] + A[k][w] && A[h][k] > 0 && A[k][w] > 0)\n R[h][w] = true\n }\n var ans = 0L\n for (h in 0 until N) for (w in h + 1 until N) {\n if (!R[h][w]) ans += A[h][w]\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfDouble() = listOfString().map { it.toDouble() }\n", "language": "Kotlin", "metadata": {"date": 1585491497, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03600.html", "problem_id": "p03600", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03600/input.txt", "sample_output_relpath": "derived/input_output/data/p03600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03600/Kotlin/s495145159.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495145159", "user_id": "u043150661"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(arg: Array) {\n val N = nextInt()\n val A = Array(N) { listOfInt() }\n val R = Array(N) { BooleanArray(N) }\n for (k in 0 until N)\n for (h in 0 until N) for (w in 0 until N) {\n if (A[h][w] > A[h][k] + A[k][w]) {\n return println(-1)\n }\n if (A[h][w] == A[h][k] + A[k][w] && A[h][k] > 0 && A[k][w] > 0)\n R[h][w] = true\n }\n var ans = 0L\n for (h in 0 until N) for (w in h + 1 until N) {\n if (!R[h][w]) ans += A[h][w]\n }\n println(ans)\n}\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun listOfString() = next().split(\" \")\nfun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfDouble() = listOfString().map { it.toDouble() }\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "sample_input": "3\n0 1 3\n1 0 2\n3 2 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03600", "source_text": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 840, "cpu_time_ms": 723, "memory_kb": 47584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s318000859", "group_id": "codeNet:p03601", "input_text": "fun main(args: Array) {\n val inputList = readLine()!!.split(' ').map(String::toInt)\n val (a, b, c, d) = inputList.subList(0, 4)\n val (e, f) = inputList.subList(4, 6)\n\n var concentration = 0.0\n var all = 0\n var sugar = 0\n for (ia in 0..(f / (100 * a))) {\n for (ib in 0..(f / (100 * b))) {\n for (ic in 0..(f / c)) {\n for (id in 0..(f / d)) {\n if (ia == 0 && ib == 0) break\n if (a * ia * 100 + b * ib * 100 + c * ic + d * id > f) break\n val n = (c * ic + d * id).toDouble() * 100.0 /\n (a * ia * 100 + b * ib * 100 + c * ic + d * id).toDouble()\n if (n > e.toDouble()) break\n if (n > concentration) {\n concentration = n\n all = a * ia * 100 + b * ib * 100 + c * ic + d * id\n sugar = c * ic + d * id\n }\n }\n }\n }\n }\n if (all == 0) all = 100 * a\n println(\"$all $sugar\")\n}", "language": "Kotlin", "metadata": {"date": 1530650768, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03601.html", "problem_id": "p03601", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03601/input.txt", "sample_output_relpath": "derived/input_output/data/p03601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03601/Kotlin/s318000859.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s318000859", "user_id": "u099066216"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "fun main(args: Array) {\n val inputList = readLine()!!.split(' ').map(String::toInt)\n val (a, b, c, d) = inputList.subList(0, 4)\n val (e, f) = inputList.subList(4, 6)\n\n var concentration = 0.0\n var all = 0\n var sugar = 0\n for (ia in 0..(f / (100 * a))) {\n for (ib in 0..(f / (100 * b))) {\n for (ic in 0..(f / c)) {\n for (id in 0..(f / d)) {\n if (ia == 0 && ib == 0) break\n if (a * ia * 100 + b * ib * 100 + c * ic + d * id > f) break\n val n = (c * ic + d * id).toDouble() * 100.0 /\n (a * ia * 100 + b * ib * 100 + c * ic + d * id).toDouble()\n if (n > e.toDouble()) break\n if (n > concentration) {\n concentration = n\n all = a * ia * 100 + b * ib * 100 + c * ic + d * id\n sugar = c * ic + d * id\n }\n }\n }\n }\n }\n if (all == 0) all = 100 * a\n println(\"$all $sugar\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03601", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1076, "cpu_time_ms": 285, "memory_kb": 36368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s669649253", "group_id": "codeNet:p03601", "input_text": "data class Satoumizu(val water:Int, val sugar:Int):Comparable{\n override fun compareTo(other: Satoumizu): Int {\n return (this.sugar * other.water).compareTo(this.water * other.sugar)\n }\n\n}\nfun main(args:Array):Unit{\n val arg = readLine()!!.split(' ').map(String::toInt).toIntArray()\n val a = arg[0] * 100\n val b = arg[1] * 100\n val c = arg[2]\n val d = arg[3]\n val e = arg[4]\n val f = arg[5]\n var max = Satoumizu(1, 0)\n for (aNum in 0 .. (f / a)){\n for (bNum in 0 .. ((f - a * aNum) / b)){\n val sugarWeight = maxSugar(minOf(f - aNum * a - bNum * b, (aNum * a + bNum * b) * e / 100), c, d)\n if (max <= Satoumizu(aNum * a + bNum * b, sugarWeight)){\n max = Satoumizu(aNum * a + bNum * b, sugarWeight)\n }\n }\n }\n println(\"${max.water + max.sugar} ${max.sugar}\")\n}\nfun maxSugar(rest:Int, c:Int, d:Int):Int{\n return (0 .. (rest / c)).map{cNum -> cNum * c + (rest - cNum * c) / d * d}.max() ?: 0\n}\nfun minOf(a:Int, b:Int):Int = if (a < b) a else b", "language": "Kotlin", "metadata": {"date": 1525548401, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03601.html", "problem_id": "p03601", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03601/input.txt", "sample_output_relpath": "derived/input_output/data/p03601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03601/Kotlin/s669649253.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669649253", "user_id": "u419330815"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "data class Satoumizu(val water:Int, val sugar:Int):Comparable{\n override fun compareTo(other: Satoumizu): Int {\n return (this.sugar * other.water).compareTo(this.water * other.sugar)\n }\n\n}\nfun main(args:Array):Unit{\n val arg = readLine()!!.split(' ').map(String::toInt).toIntArray()\n val a = arg[0] * 100\n val b = arg[1] * 100\n val c = arg[2]\n val d = arg[3]\n val e = arg[4]\n val f = arg[5]\n var max = Satoumizu(1, 0)\n for (aNum in 0 .. (f / a)){\n for (bNum in 0 .. ((f - a * aNum) / b)){\n val sugarWeight = maxSugar(minOf(f - aNum * a - bNum * b, (aNum * a + bNum * b) * e / 100), c, d)\n if (max <= Satoumizu(aNum * a + bNum * b, sugarWeight)){\n max = Satoumizu(aNum * a + bNum * b, sugarWeight)\n }\n }\n }\n println(\"${max.water + max.sugar} ${max.sugar}\")\n}\nfun maxSugar(rest:Int, c:Int, d:Int):Int{\n return (0 .. (rest / c)).map{cNum -> cNum * c + (rest - cNum * c) / d * d}.max() ?: 0\n}\nfun minOf(a:Int, b:Int):Int = if (a < b) a else b", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03601", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1068, "cpu_time_ms": 247, "memory_kb": 38300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s240466855", "group_id": "codeNet:p03607", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n println(problem073c(n, a))\n}\n\nfun problem073c(n: Int, a: List): Int {\n val a = a.toLongArray()\n val set = hashSetOf()\n for (i in 0 until n) {\n val ai = a[i]\n if (set.contains(ai)) {\n set.remove(ai)\n } else {\n set.add(ai)\n }\n }\n return set.count()\n}", "language": "Kotlin", "metadata": {"date": 1580252023, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03607.html", "problem_id": "p03607", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03607/input.txt", "sample_output_relpath": "derived/input_output/data/p03607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03607/Kotlin/s240466855.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240466855", "user_id": "u073232808"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n println(problem073c(n, a))\n}\n\nfun problem073c(n: Int, a: List): Int {\n val a = a.toLongArray()\n val set = hashSetOf()\n for (i in 0 until n) {\n val ai = a[i]\n if (set.contains(ai)) {\n set.remove(ai)\n } else {\n set.add(ai)\n }\n }\n return set.count()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "sample_input": "3\n6\n2\n6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03607", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 491, "cpu_time_ms": 749, "memory_kb": 55352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s773915156", "group_id": "codeNet:p03609", "input_text": "fun main(args: Array) {\n val (x, t) = readLine()!!.split(\" \").map { it.toInt() }\n println(if (x <= t) 0 else x - t)\n}", "language": "Kotlin", "metadata": {"date": 1579670359, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03609/input.txt", "sample_output_relpath": "derived/input_output/data/p03609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03609/Kotlin/s773915156.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s773915156", "user_id": "u088342491"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "fun main(args: Array) {\n val (x, t) = readLine()!!.split(\" \").map { it.toInt() }\n println(if (x <= t) 0 else x - t)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 238, "memory_kb": 36028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s306212384", "group_id": "codeNet:p03611", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val a = readLine()?.split(\" \")?.map(String::toInt)?.sorted() ?: return\n val count = hashMapOf()\n fun add(c: java.util.HashMap, v: Int) {\n if (c.containsKey(v)) {\n c[v] = c[v]!! + 1\n } else {\n c[v] = 1\n }\n }\n a.forEach {\n add(count, it - 1)\n add(count, it)\n add(count, it + 1)\n }\n count.maxBy { it.value }?.let {\n println(it.value.toString())\n }\n}", "language": "Kotlin", "metadata": {"date": 1589738539, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03611/input.txt", "sample_output_relpath": "derived/input_output/data/p03611/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03611/Kotlin/s306212384.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306212384", "user_id": "u979429407"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val a = readLine()?.split(\" \")?.map(String::toInt)?.sorted() ?: return\n val count = hashMapOf()\n fun add(c: java.util.HashMap, v: Int) {\n if (c.containsKey(v)) {\n c[v] = c[v]!! + 1\n } else {\n c[v] = 1\n }\n }\n a.forEach {\n add(count, it - 1)\n add(count, it)\n add(count, it + 1)\n }\n count.maxBy { it.value }?.let {\n println(it.value.toString())\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "sample_input": "7\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03611", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 536, "cpu_time_ms": 840, "memory_kb": 58212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s386454279", "group_id": "codeNet:p03612", "input_text": "import java.util.*\nimport java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nval MOD = 1000000007L\nval INF = 2147483647\nval LINF = 9223372036854775807L\n\nfun main(args: Array){\n solve()\n pw.flush() \n}\n\nfun solve(){\n readLine()\n val p = nextIntList()\n var ans = 0\n var block = 0\n for (i in p.indices) {\n val index = i + 1\n if(p[i] == index){\n block++\n } else {\n ans += (block + 1) / 2\n block = 0\n }\n }\n if(block > 0) ans += (block + 1) / 2\n\n println(ans)\n}\n\n\n// Print\nfun println(v: String){\n pw.println(v)\n}\nfun print(v: String){\n pw.print(v)\n}\n\n// Read\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map{ it.toInt() }\nfun nextLongList() = next().split(\" \").map{ it.toLong() }\nfun nextDoubleList() = next().split(\" \").map{ it.toDouble() }\nfun nextAryln(n: Int) = Array(n){ next() }\nfun nextIntAryln(n: Int) = IntArray(n){ nextInt() }\nfun nextLongAryln(n: Int) = LongArray(n){ nextLong() }\nfun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }\n\n// Math\nfun abs(n: Long) : Long = Math.abs(n)\nfun abs(n: Double) : Double = Math.abs(n)\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()\nfun prime(from: Long, to: Long = from) : List{\n return (from..to).filter{ i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all{ j -> i % j != 0L}\n }\n}\nfun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p:Long = MOD) : Long {\n var res = 1L\n var ar = a\n var nr = n\n while(nr > 0){\n if((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long) : Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n", "language": "Kotlin", "metadata": {"date": 1584791021, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03612.html", "problem_id": "p03612", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03612/input.txt", "sample_output_relpath": "derived/input_output/data/p03612/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03612/Kotlin/s386454279.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s386454279", "user_id": "u581625805"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\nimport java.io.PrintWriter\n\nval pw = PrintWriter(System.out)\nval MOD = 1000000007L\nval INF = 2147483647\nval LINF = 9223372036854775807L\n\nfun main(args: Array){\n solve()\n pw.flush() \n}\n\nfun solve(){\n readLine()\n val p = nextIntList()\n var ans = 0\n var block = 0\n for (i in p.indices) {\n val index = i + 1\n if(p[i] == index){\n block++\n } else {\n ans += (block + 1) / 2\n block = 0\n }\n }\n if(block > 0) ans += (block + 1) / 2\n\n println(ans)\n}\n\n\n// Print\nfun println(v: String){\n pw.println(v)\n}\nfun print(v: String){\n pw.print(v)\n}\n\n// Read\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = next().split(\" \").map{ it.toInt() }\nfun nextLongList() = next().split(\" \").map{ it.toLong() }\nfun nextDoubleList() = next().split(\" \").map{ it.toDouble() }\nfun nextAryln(n: Int) = Array(n){ next() }\nfun nextIntAryln(n: Int) = IntArray(n){ nextInt() }\nfun nextLongAryln(n: Int) = LongArray(n){ nextLong() }\nfun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }\n\n// Math\nfun abs(n: Long) : Long = Math.abs(n)\nfun abs(n: Double) : Double = Math.abs(n)\nfun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()\nfun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()\nfun prime(from: Long, to: Long = from) : List{\n return (from..to).filter{ i ->\n val max = Math.sqrt(i.toDouble()).toLong()\n (2..max).all{ j -> i % j != 0L}\n }\n}\nfun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p:Long = MOD) : Long {\n var res = 1L\n var ar = a\n var nr = n\n while(nr > 0){\n if((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long) : Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "sample_input": "5\n1 4 3 5 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03612", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2381, "cpu_time_ms": 492, "memory_kb": 49952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s062957683", "group_id": "codeNet:p03612", "input_text": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val aArr = readInputLine().split(\" \").map { it.toInt() - 1 }.toIntArray()\n\n var cnt = 0\n \n var i = 0\n \n while (i < N) {\n if (aArr[i] == i) {\n cnt++\n i++\n }\n i++\n }\n \n println(cnt)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1568856380, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03612.html", "problem_id": "p03612", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03612/input.txt", "sample_output_relpath": "derived/input_output/data/p03612/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03612/Kotlin/s062957683.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s062957683", "user_id": "u505558493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readInputLine().toInt()\n val aArr = readInputLine().split(\" \").map { it.toInt() - 1 }.toIntArray()\n\n var cnt = 0\n \n var i = 0\n \n while (i < N) {\n if (aArr[i] == i) {\n cnt++\n i++\n }\n i++\n }\n \n println(cnt)\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "sample_input": "5\n1 4 3 5 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03612", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 378, "cpu_time_ms": 489, "memory_kb": 51836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s493666152", "group_id": "codeNet:p03618", "input_text": "// https://atcoder.jp/contests/agc019/tasks/agc019_b\n\nfun main() {\n agc019b()\n}\n\nfun agc019b() {\n val a = readLine()!!\n val n = a.length.toLong()\n var count = (n - 1) * n / 2 + 1\n val appear = a.groupingBy { it }.eachCount()\n for (value in appear.values.map { it.toLong() }) {\n count -= (value * (value - 1) / 2)\n }\n println(count)\n}", "language": "Kotlin", "metadata": {"date": 1595564248, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03618.html", "problem_id": "p03618", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03618/input.txt", "sample_output_relpath": "derived/input_output/data/p03618/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03618/Kotlin/s493666152.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s493666152", "user_id": "u628907033"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "// https://atcoder.jp/contests/agc019/tasks/agc019_b\n\nfun main() {\n agc019b()\n}\n\nfun agc019b() {\n val a = readLine()!!\n val n = a.length.toLong()\n var count = (n - 1) * n / 2 + 1\n val appear = a.groupingBy { it }.eachCount()\n for (value in appear.values.map { it.toLong() }) {\n count -= (value * (value - 1) / 2)\n }\n println(count)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nConstraints\n\n1 \\leq |A| \\leq 200,000\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the number of different strings you can obtain by reversing any substring in A at most once.\n\nSample Input 1\n\naatt\n\nSample Output 1\n\n5\n\nYou can obtain aatt (don't do anything), atat (reverse A[2..3]), atta (reverse A[2..4]), ttaa (reverse A[1..4]) and taat (reverse A[1..3]).\n\nSample Input 2\n\nxxxxxxxxxx\n\nSample Output 2\n\n1\n\nWhatever substring you reverse, you'll always get xxxxxxxxxx.\n\nSample Input 3\n\nabracadabra\n\nSample Output 3\n\n44", "sample_input": "aatt\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03618", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nConstraints\n\n1 \\leq |A| \\leq 200,000\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the number of different strings you can obtain by reversing any substring in A at most once.\n\nSample Input 1\n\naatt\n\nSample Output 1\n\n5\n\nYou can obtain aatt (don't do anything), atat (reverse A[2..3]), atta (reverse A[2..4]), ttaa (reverse A[1..4]) and taat (reverse A[1..3]).\n\nSample Input 2\n\nxxxxxxxxxx\n\nSample Output 2\n\n1\n\nWhatever substring you reverse, you'll always get xxxxxxxxxx.\n\nSample Input 3\n\nabracadabra\n\nSample Output 3\n\n44", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 364, "cpu_time_ms": 279, "memory_kb": 42212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s152060585", "group_id": "codeNet:p03623", "input_text": "import java.math.*\n\nfun main(args: Array) {\n val (x, a, b) = readInputLine().split(\" \").map { it.toInt() }\n \n println(if (Math.abs(x - a) < Math.abs(x - b)) \"A\" else \"B\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1571274786, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03623.html", "problem_id": "p03623", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03623/input.txt", "sample_output_relpath": "derived/input_output/data/p03623/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03623/Kotlin/s152060585.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152060585", "user_id": "u505558493"}, "prompt_components": {"gold_output": "B\n", "input_to_evaluate": "import java.math.*\n\nfun main(args: Array) {\n val (x, a, b) = readInputLine().split(\" \").map { it.toInt() }\n \n println(if (Math.abs(x - a) < Math.abs(x - b)) \"A\" else \"B\")\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\n\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\n\nHere, the distance between two points s and t on a number line is represented by |s-t|.\n\nConstraints\n\n1 \\leq x \\leq 1000\n\n1 \\leq a \\leq 1000\n\n1 \\leq b \\leq 1000\n\nx, a and b are pairwise distinct.\n\nThe distances between Snuke's residence and stores A and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx a b\n\nOutput\n\nIf store A is closer, print A; if store B is closer, print B.\n\nSample Input 1\n\n5 2 7\n\nSample Output 1\n\nB\n\nThe distances between Snuke's residence and stores A and B are 3 and 2, respectively.\nSince store B is closer, print B.\n\nSample Input 2\n\n1 999 1000\n\nSample Output 2\n\nA", "sample_input": "5 2 7\n"}, "reference_outputs": ["B\n"], "source_document_id": "p03623", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\n\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\n\nHere, the distance between two points s and t on a number line is represented by |s-t|.\n\nConstraints\n\n1 \\leq x \\leq 1000\n\n1 \\leq a \\leq 1000\n\n1 \\leq b \\leq 1000\n\nx, a and b are pairwise distinct.\n\nThe distances between Snuke's residence and stores A and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx a b\n\nOutput\n\nIf store A is closer, print A; if store B is closer, print B.\n\nSample Input 1\n\n5 2 7\n\nSample Output 1\n\nB\n\nThe distances between Snuke's residence and stores A and B are 3 and 2, respectively.\nSince store B is closer, print B.\n\nSample Input 2\n\n1 999 1000\n\nSample Output 2\n\nA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 247, "cpu_time_ms": 233, "memory_kb": 35952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s852045614", "group_id": "codeNet:p03625", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n answer071cAlt(n, a)\n}\n\nfun answer071cAlt(n: Int, a: List) {\n val reversedA: MutableList = a.sortedDescending() as MutableList\n\n val set: MutableList = mutableListOf()\n var count = 0\n var firstFlg = false\n for (index: Int in reversedA.indices) {\n if (index == 0) {\n continue\n }\n if (reversedA[index] == reversedA[index - 1] && !firstFlg) {\n count += 1\n set.add(reversedA[index])\n firstFlg = true\n\n\n if (count == 2) {\n println(set)\n break\n }\n }else {\n firstFlg = false\n }\n }\n if (set.isEmpty()) {\n println(0)\n } else {\n println(set[0] * set[1])\n }\n}", "language": "Kotlin", "metadata": {"date": 1580489284, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03625.html", "problem_id": "p03625", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03625/input.txt", "sample_output_relpath": "derived/input_output/data/p03625/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03625/Kotlin/s852045614.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s852045614", "user_id": "u369142620"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n answer071cAlt(n, a)\n}\n\nfun answer071cAlt(n: Int, a: List) {\n val reversedA: MutableList = a.sortedDescending() as MutableList\n\n val set: MutableList = mutableListOf()\n var count = 0\n var firstFlg = false\n for (index: Int in reversedA.indices) {\n if (index == 0) {\n continue\n }\n if (reversedA[index] == reversedA[index - 1] && !firstFlg) {\n count += 1\n set.add(reversedA[index])\n firstFlg = true\n\n\n if (count == 2) {\n println(set)\n break\n }\n }else {\n firstFlg = false\n }\n }\n if (set.isEmpty()) {\n println(0)\n } else {\n println(set[0] * set[1])\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "sample_input": "6\n3 1 2 4 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03625", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 939, "cpu_time_ms": 802, "memory_kb": 49784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s403355059", "group_id": "codeNet:p03626", "input_text": "fun main(arg: Array) {\n val N = nextInt()\n val S1 = next()\n val S2 = next()\n val Tate = BooleanArray(N) { S1[it] == S2[it] }\n val C = LongArray(N) { n -> \n if (n == 0) if (Tate[n]) 3 else 6\n else if (!Tate[n - 1] && !Tate[n] && S1[n - 1] == S1[n]) 1\n else if (Tate[n]) if (Tate[n - 1]) 2L else 1L\n else if (Tate[n - 1]) 2L else 3L\n }\n val MOD = 1000000007L\n val ans = C.reduce { acc, c -> (acc * c) % MOD }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n\n", "language": "Kotlin", "metadata": {"date": 1585619248, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03626.html", "problem_id": "p03626", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03626/input.txt", "sample_output_relpath": "derived/input_output/data/p03626/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03626/Kotlin/s403355059.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403355059", "user_id": "u043150661"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(arg: Array) {\n val N = nextInt()\n val S1 = next()\n val S2 = next()\n val Tate = BooleanArray(N) { S1[it] == S2[it] }\n val C = LongArray(N) { n -> \n if (n == 0) if (Tate[n]) 3 else 6\n else if (!Tate[n - 1] && !Tate[n] && S1[n - 1] == S1[n]) 1\n else if (Tate[n]) if (Tate[n - 1]) 2L else 1L\n else if (Tate[n - 1]) 2L else 3L\n }\n val MOD = 1000000007L\n val ans = C.reduce { acc, c -> (acc * c) % MOD }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "sample_input": "3\naab\nccb\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03626", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 668, "cpu_time_ms": 213, "memory_kb": 33788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s372104144", "group_id": "codeNet:p03632", "input_text": "fun main(args: Array) {\n val (a, b, c, d) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n\n val low = Math.max(a, c)\n val up = Math.min(d, b)\n\n println(Math.max(0, up - low))\n}", "language": "Kotlin", "metadata": {"date": 1582295545, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03632/input.txt", "sample_output_relpath": "derived/input_output/data/p03632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03632/Kotlin/s372104144.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s372104144", "user_id": "u026352629"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c, d) = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n\n val low = Math.max(a, c)\n val up = Math.min(d, b)\n\n println(Math.max(0, up - low))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\n\nFor how many seconds both Alice and Bob were holding down their buttons?\n\nConstraints\n\n0≤A) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (A, B, C, D) = br.use { it.readLine().split(\" \").map { it.toInt() } }\n\n val ans = BooleanArray(101, { i ->\n i in A..B-1 && i in C..D-1\n })\n .fold(0) { acc, isPushed ->\n if(isPushed) acc + 1\n else acc\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1568700961, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03632/input.txt", "sample_output_relpath": "derived/input_output/data/p03632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03632/Kotlin/s174466962.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s174466962", "user_id": "u217010036"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "import java.io.InputStreamReader\nimport java.io.BufferedReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val (A, B, C, D) = br.use { it.readLine().split(\" \").map { it.toInt() } }\n\n val ans = BooleanArray(101, { i ->\n i in A..B-1 && i in C..D-1\n })\n .fold(0) { acc, isPushed ->\n if(isPushed) acc + 1\n else acc\n }\n\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\n\nFor how many seconds both Alice and Bob were holding down their buttons?\n\nConstraints\n\n0≤A) {\n abc070d()\n}\n\nprivate data class Edge(val from: Int, val to: Int, val cost: Long)\n\nfun abc070d() {\n val n = readLine()!!.toInt()\n val abcList = (1 until n)\n .map { readLine()!!.split(' ').map { it.toInt() }.let { Edge(it[0] - 1, it[1] - 1, it[2].toLong()) } }\n val (q, k) = readLine()!!.split(' ').map { it.toInt() }\n val queries = (1..q)\n .map { readLine()!!.split(' ').map { it.toInt() }.let { it[0] - 1 to it[1] - 1 } }\n\n // [from] = to, cost\n val graph = Array(n) { mutableListOf>() }\n abcList.forEach {\n val (from, to, cost) = it\n graph[from].add(to to cost)\n graph[to].add(from to cost)\n }\n\n // cost from K\n val costs = LongArray(n) { -1 }\n\n fun dfs(beforeIndex: Int, beforeCost: Long, currIndex: Int, currCost: Long) {\n costs[currIndex] = beforeCost + currCost\n\n graph[currIndex].filter { costs[it.first] == -1L }.forEach {\n val (nextIndex, nextCost) = it\n dfs(currIndex, costs[currIndex], nextIndex, nextCost)\n }\n }\n\n dfs(-1, 0, k - 1, 0)\n\n val answer = queries.map { costs[it.first] + costs[it.second] }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1577853082, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03634.html", "problem_id": "p03634", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03634/input.txt", "sample_output_relpath": "derived/input_output/data/p03634/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03634/Kotlin/s537275810.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s537275810", "user_id": "u139478771"}, "prompt_components": {"gold_output": "3\n2\n4\n", "input_to_evaluate": "fun main(args: Array) {\n abc070d()\n}\n\nprivate data class Edge(val from: Int, val to: Int, val cost: Long)\n\nfun abc070d() {\n val n = readLine()!!.toInt()\n val abcList = (1 until n)\n .map { readLine()!!.split(' ').map { it.toInt() }.let { Edge(it[0] - 1, it[1] - 1, it[2].toLong()) } }\n val (q, k) = readLine()!!.split(' ').map { it.toInt() }\n val queries = (1..q)\n .map { readLine()!!.split(' ').map { it.toInt() }.let { it[0] - 1 to it[1] - 1 } }\n\n // [from] = to, cost\n val graph = Array(n) { mutableListOf>() }\n abcList.forEach {\n val (from, to, cost) = it\n graph[from].add(to to cost)\n graph[to].add(from to cost)\n }\n\n // cost from K\n val costs = LongArray(n) { -1 }\n\n fun dfs(beforeIndex: Int, beforeCost: Long, currIndex: Int, currCost: Long) {\n costs[currIndex] = beforeCost + currCost\n\n graph[currIndex].filter { costs[it.first] == -1L }.forEach {\n val (nextIndex, nextCost) = it\n dfs(currIndex, costs[currIndex], nextIndex, nextCost)\n }\n }\n\n dfs(-1, 0, k - 1, 0)\n\n val answer = queries.map { costs[it.first] + costs[it.second] }.joinToString(System.lineSeparator())\n\n println(answer)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\n\nYou are also given Q queries and an integer K. In the j-th query (1≤j≤Q):\n\nfind the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.\n\nConstraints\n\n3≤N≤10^5\n\n1≤a_i,b_i≤N (1≤i≤N-1)\n\n1≤c_i≤10^9 (1≤i≤N-1)\n\nThe given graph is a tree.\n\n1≤Q≤10^5\n\n1≤K≤N\n\n1≤x_j,y_j≤N (1≤j≤Q)\n\nx_j≠y_j (1≤j≤Q)\n\nx_j≠K,y_j≠K (1≤j≤Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\n:\na_{N-1} b_{N-1} c_{N-1}\nQ K\nx_1 y_1\n:\nx_{Q} y_{Q}\n\nOutput\n\nPrint the responses to the queries in Q lines.\n\nIn the j-th line j(1≤j≤Q), print the response to the j-th query.\n\nSample Input 1\n\n5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n\nSample Output 1\n\n3\n2\n4\n\nThe shortest paths for the three queries are as follows:\n\nQuery 1: Vertex 2 → Vertex 1 → Vertex 2 → Vertex 4 : Length 1+1+1=3\n\nQuery 2: Vertex 2 → Vertex 1 → Vertex 3 : Length 1+1=2\n\nQuery 3: Vertex 4 → Vertex 2 → Vertex 1 → Vertex 3 → Vertex 5 : Length 1+1+1+1=4\n\nSample Input 2\n\n7\n1 2 1\n1 3 3\n1 4 5\n1 5 7\n1 6 9\n1 7 11\n3 2\n1 3\n4 5\n6 7\n\nSample Output 2\n\n5\n14\n22\n\nThe path for each query must pass Vertex K=2.\n\nSample Input 3\n\n10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10\n\nSample Output 3\n\n17000000000", "sample_input": "5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n"}, "reference_outputs": ["3\n2\n4\n"], "source_document_id": "p03634", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\n\nYou are also given Q queries and an integer K. In the j-th query (1≤j≤Q):\n\nfind the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.\n\nConstraints\n\n3≤N≤10^5\n\n1≤a_i,b_i≤N (1≤i≤N-1)\n\n1≤c_i≤10^9 (1≤i≤N-1)\n\nThe given graph is a tree.\n\n1≤Q≤10^5\n\n1≤K≤N\n\n1≤x_j,y_j≤N (1≤j≤Q)\n\nx_j≠y_j (1≤j≤Q)\n\nx_j≠K,y_j≠K (1≤j≤Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\n:\na_{N-1} b_{N-1} c_{N-1}\nQ K\nx_1 y_1\n:\nx_{Q} y_{Q}\n\nOutput\n\nPrint the responses to the queries in Q lines.\n\nIn the j-th line j(1≤j≤Q), print the response to the j-th query.\n\nSample Input 1\n\n5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n\nSample Output 1\n\n3\n2\n4\n\nThe shortest paths for the three queries are as follows:\n\nQuery 1: Vertex 2 → Vertex 1 → Vertex 2 → Vertex 4 : Length 1+1+1=3\n\nQuery 2: Vertex 2 → Vertex 1 → Vertex 3 : Length 1+1=2\n\nQuery 3: Vertex 4 → Vertex 2 → Vertex 1 → Vertex 3 → Vertex 5 : Length 1+1+1+1=4\n\nSample Input 2\n\n7\n1 2 1\n1 3 3\n1 4 5\n1 5 7\n1 6 9\n1 7 11\n3 2\n1 3\n4 5\n6 7\n\nSample Output 2\n\n5\n14\n22\n\nThe path for each query must pass Vertex K=2.\n\nSample Input 3\n\n10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10\n\nSample Output 3\n\n17000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1244, "cpu_time_ms": 1484, "memory_kb": 131928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s544936705", "group_id": "codeNet:p03635", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (n, m) = listOfInt()\n println((n-1)*(m-1))\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt()= listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1565085294, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03635.html", "problem_id": "p03635", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03635/input.txt", "sample_output_relpath": "derived/input_output/data/p03635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03635/Kotlin/s544936705.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s544936705", "user_id": "u262403099"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (n, m) = listOfInt()\n println((n-1)*(m-1))\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt()= listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "sample_input": "3 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03635", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 391, "cpu_time_ms": 240, "memory_kb": 36208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s384298447", "group_id": "codeNet:p03636", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n println(\"${s.first()}${s.length - 2}${s.last()}\")\n}\n", "language": "Kotlin", "metadata": {"date": 1553489330, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03636.html", "problem_id": "p03636", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03636/input.txt", "sample_output_relpath": "derived/input_output/data/p03636/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03636/Kotlin/s384298447.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s384298447", "user_id": "u051841332"}, "prompt_components": {"gold_output": "i18n\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n println(\"${s.first()}${s.length - 2}${s.last()}\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|s| denotes the length of s.)\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "sample_input": "internationalization\n"}, "reference_outputs": ["i18n\n"], "source_document_id": "p03636", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|s| denotes the length of s.)\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 113, "cpu_time_ms": 207, "memory_kb": 33744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s091292541", "group_id": "codeNet:p03637", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n println(problem069c(n, a))\n}\n\nfun problem069c(n: Int, a: List): String {\n val fours = a.filter { it % 4 == 0L }\n val twoCount = a.filter { it == 2L }\n return if (fours.size + twoCount.size / 2L >= n / 2) \"Yes\" else \"No\"\n}", "language": "Kotlin", "metadata": {"date": 1578537764, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03637/input.txt", "sample_output_relpath": "derived/input_output/data/p03637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03637/Kotlin/s091292541.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s091292541", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val a = (0 until n).map { sc.next().toLong() }\n println(problem069c(n, a))\n}\n\nfun problem069c(n: Int, a: List): String {\n val fours = a.filter { it % 4 == 0L }\n val twoCount = a.filter { it == 2L }\n return if (fours.size + twoCount.size / 2L >= n / 2) \"Yes\" else \"No\"\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "sample_input": "3\n1 10 100\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03637", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 402, "cpu_time_ms": 643, "memory_kb": 51744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s402980411", "group_id": "codeNet:p03637", "input_text": "fun main(args:Array) {\n val n = readLine()!!\n var xs = readLine()!!.split(\" \").map(String::toInt)\n\n val quads = xs.filter { it%4 == 0 }.size\n xs = xs.filter { it%4 != 0 } \n\n val twices = xs.filter { it%2 == 0 }.size\n xs = xs.filter { it%2 != 0 } \n\n val noks = xs.size\n\n when { \n (noks - quads) <= 1 && twices == 0 -> \"Yes\"\n noks <= quads && twices > 0 -> \"Yes\"\n else -> \"No\"\n }.run(::println)\n\n //println( noks - quads )\n}\n", "language": "Kotlin", "metadata": {"date": 1558149956, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03637/input.txt", "sample_output_relpath": "derived/input_output/data/p03637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03637/Kotlin/s402980411.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402980411", "user_id": "u227189389"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args:Array) {\n val n = readLine()!!\n var xs = readLine()!!.split(\" \").map(String::toInt)\n\n val quads = xs.filter { it%4 == 0 }.size\n xs = xs.filter { it%4 != 0 } \n\n val twices = xs.filter { it%2 == 0 }.size\n xs = xs.filter { it%2 != 0 } \n\n val noks = xs.size\n\n when { \n (noks - quads) <= 1 && twices == 0 -> \"Yes\"\n noks <= quads && twices > 0 -> \"Yes\"\n else -> \"No\"\n }.run(::println)\n\n //println( noks - quads )\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "sample_input": "3\n1 10 100\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03637", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 453, "cpu_time_ms": 514, "memory_kb": 57836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s222754133", "group_id": "codeNet:p03638", "input_text": "fun main(args: Array) {\n val (H, W) = readInputLine().split(\" \").map { it.toInt() }\n readInputLine()\n val aList = readInputLine().split(\" \").map { it.toInt() }\n \n val ans = Array(H, { IntArray(W) } )\n var nowH = 0\n var nowW = 0\n \n for ((index, a) in aList.withIndex()) {\n for (j in 1..a) {\n ans[nowH][nowW] = index + 1\n if (nowH % 2 == 0) {\n nowW++\n if (nowW >= W) {\n nowW--\n nowH++\n }\n } else {\n nowW--\n if (nowW < 0) {\n nowW++\n nowH++\n }\n }\n }\n }\n \n for (a in ans) {\n println(a.joinToString(\" \"))\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1569246464, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03638.html", "problem_id": "p03638", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03638/input.txt", "sample_output_relpath": "derived/input_output/data/p03638/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03638/Kotlin/s222754133.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s222754133", "user_id": "u505558493"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "fun main(args: Array) {\n val (H, W) = readInputLine().split(\" \").map { it.toInt() }\n readInputLine()\n val aList = readInputLine().split(\" \").map { it.toInt() }\n \n val ans = Array(H, { IntArray(W) } )\n var nowH = 0\n var nowW = 0\n \n for ((index, a) in aList.withIndex()) {\n for (j in 1..a) {\n ans[nowH][nowW] = index + 1\n if (nowH % 2 == 0) {\n nowW++\n if (nowW >= W) {\n nowW--\n nowH++\n }\n } else {\n nowW--\n if (nowW < 0) {\n nowW++\n nowH++\n }\n }\n }\n }\n \n for (a in ans) {\n println(a.joinToString(\" \"))\n }\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "sample_input": "2 2\n3\n2 1 1\n"}, "reference_outputs": ["1 1\n2 3\n"], "source_document_id": "p03638", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 839, "cpu_time_ms": 441, "memory_kb": 41128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s808430240", "group_id": "codeNet:p03643", "input_text": "\nimport java.util.*\n\nfun main( argv : Array ) {\n \n val scan = Scanner(System.`in`)\n \n //\n val S = scan.next()\n //\n println( \"ABC\"+S )\n\n}\n\n", "language": "Kotlin", "metadata": {"date": 1503520268, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03643.html", "problem_id": "p03643", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03643/input.txt", "sample_output_relpath": "derived/input_output/data/p03643/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03643/Kotlin/s808430240.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808430240", "user_id": "u951750034"}, "prompt_components": {"gold_output": "ABC100\n", "input_to_evaluate": "\nimport java.util.*\n\nfun main( argv : Array ) {\n \n val scan = Scanner(System.`in`)\n \n //\n val S = scan.next()\n //\n println( \"ABC\"+S )\n\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "sample_input": "100\n"}, "reference_outputs": ["ABC100\n"], "source_document_id": "p03643", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 167, "cpu_time_ms": 178, "memory_kb": 29728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s851264003", "group_id": "codeNet:p03644", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val arr = arrayOf(1,2,4,8,16,32,64,128)\n for (i in arr.indices) {\n if (arr[i+1] > n) {\n println(arr[i])\n break\n }\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1530129471, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03644/input.txt", "sample_output_relpath": "derived/input_output/data/p03644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03644/Kotlin/s851264003.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851264003", "user_id": "u396701320"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val arr = arrayOf(1,2,4,8,16,32,64,128)\n for (i in arr.indices) {\n if (arr[i+1] > n) {\n println(arr[i])\n break\n }\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 220, "memory_kb": 35772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s346825999", "group_id": "codeNet:p03646", "input_text": "fun main(args: Array) {\n val K = readLine()!!.toLong()\n if (K == 0L) {\n println(1)\n println(0)\n return\n }\n\n val aiMax = 10000000000000000L + 1000L\n (2..50).forEach { n ->\n val N = n.toLong()\n var upper = Math.min((K + 1) * N -1, aiMax)\n var lower = N + 2 * K\n if (lower <= upper) {\n val a = LongArray(N.toInt()) { 0 }\n a[0] = lower\n\n println(N)\n println(a.joinToString(\" \"))\n return\n }\n\n }\n}", "language": "Kotlin", "metadata": {"date": 1569989543, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03646.html", "problem_id": "p03646", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03646/input.txt", "sample_output_relpath": "derived/input_output/data/p03646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03646/Kotlin/s346825999.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s346825999", "user_id": "u861095163"}, "prompt_components": {"gold_output": "4\n3 3 3 3\n", "input_to_evaluate": "fun main(args: Array) {\n val K = readLine()!!.toLong()\n if (K == 0L) {\n println(1)\n println(0)\n return\n }\n\n val aiMax = 10000000000000000L + 1000L\n (2..50).forEach { n ->\n val N = n.toLong()\n var upper = Math.min((K + 1) * N -1, aiMax)\n var lower = N + 2 * K\n if (lower <= upper) {\n val a = LongArray(N.toInt()) { 0 }\n a[0] = lower\n\n println(N)\n println(a.joinToString(\" \"))\n return\n }\n\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.\n\nDetermine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.\n\nIt can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.\n\nYou are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.\n\nConstraints\n\n0 ≤ K ≤ 50 \\times 10^{16}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint a solution in the following format:\n\nN\na_1 a_2 ... a_N\n\nHere, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.\n\nSample Input 1\n\n0\n\nSample Output 1\n\n4\n3 3 3 3\n\nSample Input 2\n\n1\n\nSample Output 2\n\n3\n1 0 3\n\nSample Input 3\n\n2\n\nSample Output 3\n\n2\n2 2\n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\nSample Input 4\n\n3\n\nSample Output 4\n\n7\n27 0 0 0 0 0 0\n\nSample Input 5\n\n1234567894848\n\nSample Output 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425", "sample_input": "0\n"}, "reference_outputs": ["4\n3 3 3 3\n"], "source_document_id": "p03646", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.\n\nDetermine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.\n\nIt can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.\n\nYou are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.\n\nConstraints\n\n0 ≤ K ≤ 50 \\times 10^{16}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint a solution in the following format:\n\nN\na_1 a_2 ... a_N\n\nHere, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.\n\nSample Input 1\n\n0\n\nSample Output 1\n\n4\n3 3 3 3\n\nSample Input 2\n\n1\n\nSample Output 2\n\n3\n1 0 3\n\nSample Input 3\n\n2\n\nSample Output 3\n\n2\n2 2\n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\nSample Input 4\n\n3\n\nSample Output 4\n\n7\n27 0 0 0 0 0 0\n\nSample Input 5\n\n1234567894848\n\nSample Output 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 528, "cpu_time_ms": 220, "memory_kb": 33976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s930687950", "group_id": "codeNet:p03657", "input_text": "fun main(args: Array) {\n abc067a()\n}\n\nfun abc067a() {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = listOf(a, b, a + b).any { it % 3 == 0 }.let { if (it) \"Possible\" else \"Impossible\" }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1572117701, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03657/input.txt", "sample_output_relpath": "derived/input_output/data/p03657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03657/Kotlin/s930687950.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930687950", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "fun main(args: Array) {\n abc067a()\n}\n\nfun abc067a() {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n val answer = listOf(a, b, a + b).any { it % 3 == 0 }.let { if (it) \"Possible\" else \"Impossible\" }\n\n println(answer)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 251, "cpu_time_ms": 237, "memory_kb": 35940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s321544594", "group_id": "codeNet:p03657", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n println(if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) \"Possible\" else \"Impossible\")\n}\n", "language": "Kotlin", "metadata": {"date": 1552794227, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03657/input.txt", "sample_output_relpath": "derived/input_output/data/p03657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03657/Kotlin/s321544594.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s321544594", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ').map(String::toInt)\n println(if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) \"Possible\" else \"Impossible\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 235, "memory_kb": 38176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s438770867", "group_id": "codeNet:p03657", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val ans = if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 ==0) {\n \"Possible\"\n } else {\n \"Impossible\"\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1500186946, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03657/input.txt", "sample_output_relpath": "derived/input_output/data/p03657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03657/Kotlin/s438770867.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s438770867", "user_id": "u491074504"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val ans = if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 ==0) {\n \"Possible\"\n } else {\n \"Impossible\"\n }\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 280, "cpu_time_ms": 173, "memory_kb": 31132}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s453104733", "group_id": "codeNet:p03660", "input_text": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val nodes: Array = Array(n.toInt()) { Node(it.toLong()) }\n for (i in 0 until n - 1) {\n val a = nextLong() - 1\n val b = nextLong() - 1\n nodes[a].edges.add(Edge(a, b, 1))\n nodes[b].edges.add(Edge(b, a, 1))\n }\n\n val adist = bfs(nodes, 0)\n val bdist = bfs(nodes, n - 1)\n var a = 0L\n var b = 0L\n for (i in 0 until n) {\n if(adist[i] <= bdist[i]) a++\n else b++\n }\n\n println(if(a > b) \"Fennec\" else \"Snuke\")\n\n\n}\n\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1589414328, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03660.html", "problem_id": "p03660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03660/input.txt", "sample_output_relpath": "derived/input_output/data/p03660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03660/Kotlin/s453104733.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453104733", "user_id": "u581625805"}, "prompt_components": {"gold_output": "Fennec\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.math.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextLong()\n val nodes: Array = Array(n.toInt()) { Node(it.toLong()) }\n for (i in 0 until n - 1) {\n val a = nextLong() - 1\n val b = nextLong() - 1\n nodes[a].edges.add(Edge(a, b, 1))\n nodes[b].edges.add(Edge(b, a, 1))\n }\n\n val adist = bfs(nodes, 0)\n val bdist = bfs(nodes, n - 1)\n var a = 0L\n var b = 0L\n for (i in 0 until n) {\n if(adist[i] <= bdist[i]) a++\n else b++\n }\n\n println(if(a > b) \"Fennec\" else \"Snuke\")\n\n\n}\n\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun IntArray.get(index: Long): Int {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun IntArray.set(index: Long, value: Int) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass GridGraph(\n private val h: Long,\n private val w: Long,\n val nodes: Array = Array((h * w).toInt()) { Node(it.toLong()) },\n private val edges: IntArray = IntArray((h * w).toInt()) { 0 }\n) {\n private val up = 1\n private val right = 2\n private val down = 4\n private val left = 8\n private val queue: ArrayDeque = ArrayDeque()\n private val startPos = longList()\n\n private fun pos(y: Long, x: Long) = y * w + x\n fun canUp(v: Long) = (edges[v] and 1) == 1\n fun canRight(v: Long) = ((edges[v] shr 1) and 1) == 1\n fun canDown(v: Long) = ((edges[v] shr 2) and 1) == 1\n fun canLeft(v: Long) = ((edges[v] shr 3) and 1) == 1\n\n fun init(s: Array, check: Char = '.', road: Char = '.', start: Char = 'S') {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if(s[i][j] != check && s[i][j] != start) continue\n if(i > 0 && s[i - 1][j] == road) edges[pos(i, j)] += up\n if(i < h - 1 && s[i + 1][j] == road) edges[pos(i, j)] += down\n if(j > 0 && s[i][j - 1] == road) edges[pos(i, j)] += left\n if(j < w - 1 && s[i][j + 1] == road) edges[pos(i, j)] += right\n if(s[i][j] == start) {\n queue.add(pos(i, j))\n startPos.add(pos(i, j))\n }\n }\n }\n }\n fun addStart(y: Long, x: Long) {\n startPos.add(pos(y, x))\n queue.add(pos(y, x))\n }\n\n fun bfs(): LongArray {\n val dist = longAry(h * w, -1L)\n for (i in startPos) {\n dist[i] = 0L\n }\n while (queue.isNotEmpty()) {\n val v = queue.poll()\n if(canUp(v) && dist[v - w] == -1L) {\n queue.add(v - w)\n dist[v - w] = dist[v] + 1L\n }\n if(canDown(v) && dist[v + w] == -1L) {\n queue.add(v + w)\n dist[v + w] = dist[v] + 1L\n }\n if(canLeft(v) && dist[v - 1] == -1L) {\n queue.add(v - 1)\n dist[v - 1] = dist[v] + 1L\n }\n if(canRight(v) && dist[v + 1] == -1L) {\n queue.add(v + 1)\n dist[v + 1] = dist[v] + 1L\n }\n }\n return dist\n }\n\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "sample_input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"}, "reference_outputs": ["Fennec\n"], "source_document_id": "p03660", "source_text": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 17238, "cpu_time_ms": 616, "memory_kb": 79444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s117030572", "group_id": "codeNet:p03665", "input_text": "import java.util.*\n\n/**\n * Created by zzt on 17-7-11.\n */\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val p = scanner.nextInt()\n var hasOdd = false\n\n for (i in 1..n) {\n if (scanner.nextInt() % 2 != 0) {\n hasOdd = true\n break\n }\n }\n\n println(if (hasOdd) Math.pow(2.0, (n - 1).toDouble()).toLong() else Math.pow(2.0, n.toDouble()).toLong())\n}", "language": "Kotlin", "metadata": {"date": 1499803466, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03665.html", "problem_id": "p03665", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03665/input.txt", "sample_output_relpath": "derived/input_output/data/p03665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03665/Kotlin/s117030572.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s117030572", "user_id": "u324614336"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*\n\n/**\n * Created by zzt on 17-7-11.\n */\n\nfun main(args: Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val p = scanner.nextInt()\n var hasOdd = false\n\n for (i in 1..n) {\n if (scanner.nextInt() % 2 != 0) {\n hasOdd = true\n break\n }\n }\n\n println(if (hasOdd) Math.pow(2.0, (n - 1).toDouble()).toLong() else Math.pow(2.0, n.toDouble()).toLong())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside.\nHere, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.\nHow many such ways to select bags there are?\n\nConstraints\n\n1 \\leq N \\leq 50\n\nP = 0 or 1\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.\n\nSample Input 1\n\n2 0\n1 3\n\nSample Output 1\n\n2\n\nThere are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:\n\nSelect neither bag. The total number of biscuits is 0.\n\nSelect both bags. The total number of biscuits is 4.\n\nSample Input 2\n\n1 1\n50\n\nSample Output 2\n\n0\n\nSample Input 3\n\n3 0\n1 1 1\n\nSample Output 3\n\n4\n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\nSample Input 4\n\n45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26\n\nSample Output 4\n\n17592186044416", "sample_input": "2 0\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03665", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside.\nHere, it is also possible to select all or none of the bags.\n\nHe would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.\nHow many such ways to select bags there are?\n\nConstraints\n\n1 \\leq N \\leq 50\n\nP = 0 or 1\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.\n\nSample Input 1\n\n2 0\n1 3\n\nSample Output 1\n\n2\n\nThere are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:\n\nSelect neither bag. The total number of biscuits is 0.\n\nSelect both bags. The total number of biscuits is 4.\n\nSample Input 2\n\n1 1\n50\n\nSample Output 2\n\n0\n\nSample Input 3\n\n3 0\n1 1 1\n\nSample Output 3\n\n4\n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\nSample Input 4\n\n45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26\n\nSample Output 4\n\n17592186044416", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 450, "cpu_time_ms": 187, "memory_kb": 31136}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s639343467", "group_id": "codeNet:p03672", "input_text": "fun main(arr: Array) {\n val s = readLine()!!\n val ans = (1 until s.length).map { s.dropLast(it) }.filter { it.take(it.length/2) == it.drop(it.length/2) }.map { it.length }.max()\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1600029028, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03672.html", "problem_id": "p03672", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03672/input.txt", "sample_output_relpath": "derived/input_output/data/p03672/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03672/Kotlin/s639343467.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639343467", "user_id": "u269969976"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main(arr: Array) {\n val s = readLine()!!\n val ans = (1 until s.length).map { s.dropLast(it) }.filter { it.take(it.length/2) == it.drop(it.length/2) }.map { it.length }.max()\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "sample_input": "abaababaab\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03672", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 211, "cpu_time_ms": 128, "memory_kb": 36784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s089175138", "group_id": "codeNet:p03672", "input_text": "fun main() {\n val s = readLine()!!.trim()\n\n for (i in 1 until s.length.div(2)) {\n val ss = s.dropLast(i * 2)\n val mid = ss.length.div(2)\n\n val a = ss.slice(0 until mid)\n val b = ss.slice(mid .. ss.lastIndex)\n\n if(a == b){\n print(ss.length)\n return\n }\n }\n print(-1)\n}\n", "language": "Kotlin", "metadata": {"date": 1597612145, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03672.html", "problem_id": "p03672", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03672/input.txt", "sample_output_relpath": "derived/input_output/data/p03672/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03672/Kotlin/s089175138.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089175138", "user_id": "u824734140"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "fun main() {\n val s = readLine()!!.trim()\n\n for (i in 1 until s.length.div(2)) {\n val ss = s.dropLast(i * 2)\n val mid = ss.length.div(2)\n\n val a = ss.slice(0 until mid)\n val b = ss.slice(mid .. ss.lastIndex)\n\n if(a == b){\n print(ss.length)\n return\n }\n }\n print(-1)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "sample_input": "abaababaab\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03672", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 344, "cpu_time_ms": 118, "memory_kb": 36052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s807166739", "group_id": "codeNet:p03672", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n\n val n = s.length\n\n for (i in 1 until n) {\n val sub = s.substring(0, n - i)\n\n val len = sub.length\n if (len % 2 != 0) {\n continue\n }\n\n val first = sub.substring(0, len / 2)\n val second = sub.substring(len / 2)\n if (first == second) {\n println(len)\n return\n }\n }\n\n}\n", "language": "Kotlin", "metadata": {"date": 1592964074, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03672.html", "problem_id": "p03672", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03672/input.txt", "sample_output_relpath": "derived/input_output/data/p03672/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03672/Kotlin/s807166739.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s807166739", "user_id": "u323522006"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val s = sc.next()\n\n val n = s.length\n\n for (i in 1 until n) {\n val sub = s.substring(0, n - i)\n\n val len = sub.length\n if (len % 2 != 0) {\n continue\n }\n\n val first = sub.substring(0, len / 2)\n val second = sub.substring(len / 2)\n if (first == second) {\n println(len)\n return\n }\n }\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "sample_input": "abaababaab\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03672", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 412, "cpu_time_ms": 125, "memory_kb": 36236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s484191692", "group_id": "codeNet:p03673", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val map = if (n and 1 == 0) {\n { i: Int -> (n shr 1) + ((i + 1) shr 1) * Math.pow(-1.0, i.toDouble()).toInt() }\n } else {\n { i: Int -> (n shr 1) - ((i + 1) shr 1) * Math.pow(-1.0, i.toDouble()).toInt() }\n }\n val b = arrayOfNulls(n)\n readLine()!!.split(' ').forEachIndexed { i, a ->\n b[map(i)] = a\n }\n println(b.joinToString(\" \"))\n}\n", "language": "Kotlin", "metadata": {"date": 1552968687, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03673.html", "problem_id": "p03673", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03673/input.txt", "sample_output_relpath": "derived/input_output/data/p03673/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03673/Kotlin/s484191692.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s484191692", "user_id": "u051841332"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val map = if (n and 1 == 0) {\n { i: Int -> (n shr 1) + ((i + 1) shr 1) * Math.pow(-1.0, i.toDouble()).toInt() }\n } else {\n { i: Int -> (n shr 1) - ((i + 1) shr 1) * Math.pow(-1.0, i.toDouble()).toInt() }\n }\n val b = arrayOfNulls(n)\n readLine()!!.split(' ').forEachIndexed { i, a ->\n b[map(i)] = a\n }\n println(b.joinToString(\" \"))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "sample_input": "4\n1 2 3 4\n"}, "reference_outputs": ["4 2 1 3\n"], "source_document_id": "p03673", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 448, "cpu_time_ms": 582, "memory_kb": 82944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s344788483", "group_id": "codeNet:p03679", "input_text": "fun main(args: Array) {\n a65(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\nfun a65(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val (x, tillExpire, days) = args[0].split(\" \").map { it.toInt() }\n println(when {\n tillExpire - days >= 0 -> \"delicious\"\n days - tillExpire <= x -> \"safe\"\n else -> \"dangerous\"\n })\n}", "language": "Kotlin", "metadata": {"date": 1540345435, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03679.html", "problem_id": "p03679", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03679/input.txt", "sample_output_relpath": "derived/input_output/data/p03679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03679/Kotlin/s344788483.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s344788483", "user_id": "u227166381"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "fun main(args: Array) {\n a65(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\nfun a65(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val (x, tillExpire, days) = args[0].split(\" \").map { it.toInt() }\n println(when {\n tillExpire - days >= 0 -> \"delicious\"\n days - tillExpire <= x -> \"safe\"\n else -> \"dangerous\"\n })\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\n\nOther than that, he finds the food delicious if he eats it not later than the \"best-by\" date. Otherwise, he does not find it delicious.\n\nTakahashi bought some food A days before the \"best-by\" date, and ate it B days after he bought it.\n\nWrite a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.\n\nConstraints\n\n1 ≤ X,A,B ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A B\n\nOutput\n\nPrint delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.\n\nSample Input 1\n\n4 3 6\n\nSample Output 1\n\nsafe\n\nHe ate the food three days after the \"best-by\" date. It was not delicious or harmful for him.\n\nSample Input 2\n\n6 5 1\n\nSample Output 2\n\ndelicious\n\nHe ate the food by the \"best-by\" date. It was delicious for him.\n\nSample Input 3\n\n3 7 12\n\nSample Output 3\n\ndangerous\n\nHe ate the food five days after the \"best-by\" date. It was harmful for him.", "sample_input": "4 3 6\n"}, "reference_outputs": ["safe\n"], "source_document_id": "p03679", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\n\nOther than that, he finds the food delicious if he eats it not later than the \"best-by\" date. Otherwise, he does not find it delicious.\n\nTakahashi bought some food A days before the \"best-by\" date, and ate it B days after he bought it.\n\nWrite a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.\n\nConstraints\n\n1 ≤ X,A,B ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A B\n\nOutput\n\nPrint delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.\n\nSample Input 1\n\n4 3 6\n\nSample Output 1\n\nsafe\n\nHe ate the food three days after the \"best-by\" date. It was not delicious or harmful for him.\n\nSample Input 2\n\n6 5 1\n\nSample Output 2\n\ndelicious\n\nHe ate the food by the \"best-by\" date. It was delicious for him.\n\nSample Input 3\n\n3 7 12\n\nSample Output 3\n\ndangerous\n\nHe ate the food five days after the \"best-by\" date. It was harmful for him.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 661, "cpu_time_ms": 237, "memory_kb": 37960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s070266688", "group_id": "codeNet:p03680", "input_text": "fun main(array: Array) {\n val n = readLine()!!.toInt()\n val list = mutableListOf()\n repeat(n) {\n list.add(readLine()!!.toInt())\n }\n var cnt = 0\n var idx = 1\n while (cnt <= n) {\n if(idx == 2) {\n print(cnt)\n return\n }\n else {\n cnt++\n idx = list[idx-1]\n }\n }\n print(-1)\n}", "language": "Kotlin", "metadata": {"date": 1592944220, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03680/input.txt", "sample_output_relpath": "derived/input_output/data/p03680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03680/Kotlin/s070266688.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s070266688", "user_id": "u124119858"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(array: Array) {\n val n = readLine()!!.toInt()\n val list = mutableListOf()\n repeat(n) {\n list.add(readLine()!!.toInt())\n }\n var cnt = 0\n var idx = 1\n while (cnt <= n) {\n if(idx == 2) {\n print(cnt)\n return\n }\n else {\n cnt++\n idx = list[idx-1]\n }\n }\n print(-1)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 387, "cpu_time_ms": 298, "memory_kb": 58452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s555669490", "group_id": "codeNet:p03680", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextInt()\n var aa = mutableListOf()\n val flags = Array(n){false}\n\n repeat(n) {\n aa.add(nextInt())\n }\n\n var nextIndex = 0\n var cnt = 0\n for (i in 0 until n) {\n cnt++\n if (aa[nextIndex] == 2) {\n println(cnt)\n return\n }\n if (flags[nextIndex]) {\n println(-1)\n return\n }\n flags[nextIndex] = true\n nextIndex = aa[nextIndex] - 1\n }\n\n println(-1)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1568704204, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03680/input.txt", "sample_output_relpath": "derived/input_output/data/p03680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03680/Kotlin/s555669490.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s555669490", "user_id": "u262403099"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val n = nextInt()\n var aa = mutableListOf()\n val flags = Array(n){false}\n\n repeat(n) {\n aa.add(nextInt())\n }\n\n var nextIndex = 0\n var cnt = 0\n for (i in 0 until n) {\n cnt++\n if (aa[nextIndex] == 2) {\n println(cnt)\n return\n }\n if (flags[nextIndex]) {\n println(-1)\n return\n }\n flags[nextIndex] = true\n nextIndex = aa[nextIndex] - 1\n }\n\n println(-1)\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 730, "cpu_time_ms": 424, "memory_kb": 40860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s474943374", "group_id": "codeNet:p03693", "input_text": "fun ans (i: String, j: String, k: String): String {\n return if ((i + j + k).toInt() % 4 == 0) \"YES\" else \"NO\"\n}\n\nfun main (args: Array) {\n val col = readLine()!!.split(\" \")\n println(ans(col[0], col[1], col[2]))\n}\n", "language": "Kotlin", "metadata": {"date": 1569806781, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/Kotlin/s474943374.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s474943374", "user_id": "u454524105"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun ans (i: String, j: String, k: String): String {\n return if ((i + j + k).toInt() % 4 == 0) \"YES\" else \"NO\"\n}\n\nfun main (args: Array) {\n val col = readLine()!!.split(\" \")\n println(ans(col[0], col[1], col[2]))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 235, "memory_kb": 36024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s250509364", "group_id": "codeNet:p03693", "input_text": "fun main(args: Array) {\n val (r, g, b) = readLine()!!.split(\" \").map { it.toInt() }\n when {\n (10 * g + b) % 4 == 0 -> println(\"YES\")\n else -> println(\"NO\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1569230841, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/Kotlin/s250509364.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s250509364", "user_id": "u993090205"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (r, g, b) = readLine()!!.split(\" \").map { it.toInt() }\n when {\n (10 * g + b) % 4 == 0 -> println(\"YES\")\n else -> println(\"NO\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 192, "cpu_time_ms": 246, "memory_kb": 36112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s920125190", "group_id": "codeNet:p03693", "input_text": "fun main(args: Array) {\n println(if (readLine()!!.replace(\" \".toRegex(), \"\").toInt() % 4 == 0) \"YES\" else \"NO\")\n}\n", "language": "Kotlin", "metadata": {"date": 1552439915, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/Kotlin/s920125190.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s920125190", "user_id": "u051841332"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n println(if (readLine()!!.replace(\" \".toRegex(), \"\").toInt() % 4 == 0) \"YES\" else \"NO\")\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 125, "cpu_time_ms": 218, "memory_kb": 31988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s773739893", "group_id": "codeNet:p03695", "input_text": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val aList = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n\n val result = mutableSetOf()\n var overRed = 0\n\n for (a in aList) {\n when (a) {\n in 1..399 -> {\n result += 0\n }\n in 400..799 -> {\n result += 1\n }\n in 800..1199 -> {\n result += 2\n }\n in 1200..1599 -> {\n result += 3\n }\n in 1600..1999 -> {\n result += 4\n }\n in 2000..2399 -> {\n result += 5\n }\n in 2400..2799 -> {\n result += 6\n }\n in 2800..3199 -> {\n result += 7\n }\n else -> {\n overRed++\n }\n }\n }\n val min = if (result.isEmpty()) 1 else result.size\n val max = Math.min(8, (result.size + overRed))\n\n println(\"$min $max\")\n}", "language": "Kotlin", "metadata": {"date": 1589247974, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03695/input.txt", "sample_output_relpath": "derived/input_output/data/p03695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03695/Kotlin/s773739893.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s773739893", "user_id": "u026352629"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toInt() ?: return\n val aList = readLine()?.split(\" \")?.map { it.toInt() } ?: return\n\n val result = mutableSetOf()\n var overRed = 0\n\n for (a in aList) {\n when (a) {\n in 1..399 -> {\n result += 0\n }\n in 400..799 -> {\n result += 1\n }\n in 800..1199 -> {\n result += 2\n }\n in 1200..1599 -> {\n result += 3\n }\n in 1600..1999 -> {\n result += 4\n }\n in 2000..2399 -> {\n result += 5\n }\n in 2400..2799 -> {\n result += 6\n }\n in 2800..3199 -> {\n result += 7\n }\n else -> {\n overRed++\n }\n }\n }\n val min = if (result.isEmpty()) 1 else result.size\n val max = Math.min(8, (result.size + overRed))\n\n println(\"$min $max\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1032, "cpu_time_ms": 238, "memory_kb": 37776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s748620955", "group_id": "codeNet:p03699", "input_text": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextInt()\n val s = nextIntAry(n)\n var sum = s.sum()\n s.sort()\n for (i in s.indices){\n if(sum % 10 != 0) break\n sum -= s[i]\n }\n\n println(sum)\n\n}\n\n\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = sc.next()\nfun nextInt() = sc.nextInt()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Int): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextIntAry(n: Int): IntArray {\n val ary = intAry(n)\n for (i in 0 until n) ary[i] = nextInt()\n return ary\n}\nfun nextLongAry(n: Int): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Int): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\nfun list() = mutableListOf()\nfun intList() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun intSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\nfun Int.a() = this.toLong()\nfun Long.a() = this.toInt()\nfun IntArray.lowerBound(n: Int) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.lowerBound(n: Long) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.intLowerBound(n: Int) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun IntArray.cumsum(): IntArray {\n val s = intAry(this.size + 1)\n for (i in this.indices) s[i + 1] = s[i] + this[i]\n return s\n}\nfun LongArray.cumsum(): LongArray {\n val s = longAry(this.size + 1)\n for (i in this.indices) s[i + 1] = s[i] + this[i]\n return s\n}\nfun MutableMap.counting(n: Int) {\n repeat(n){\n val a = next()\n if(this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.intCounting(n: Int) {\n repeat(n){\n val a = nextInt()\n if(this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Int) {\n repeat(n){\n val a = nextLong()\n if(this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!\nfun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!\nfun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!\nfun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!\ntailrec fun gcd(a: Int, b: Int) : Int = if(a % b == 0) b else gcd(b, (a % b))\ntailrec fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Int, b: Int) : Int = a / gcd(a, b) * b\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Int) {\n private val fac = LongArray(max)\n private val finv = LongArray(max)\n private val inv = LongArray(max)\n private val p = MOD.a()\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Int, r: Int): Long = if (n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Int, private var searched: Int = 0, private var nextIndex: Int = 0) {\n private val size = fact(n)\n private val permList = Array(size) { IntArray(n) { 0 } }\n\n private tailrec fun fact(n: Int, ans: Int = 1): Int {\n return if (n == 0) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, IntArray(n) { 0 }, Array(n) { false })\n }\n\n private fun create(num: Int, list: IntArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): IntArray = permList[nextIndex++]\n}\n\n\ndata class Node(val id: Int, var past: Int = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Int, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Int): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size, -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Int): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size, LINF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass UnionFind(size: Int){\n private val par = IntArray(size) { it }\n private val size = IntArray(size) { 1 }\n fun root(x: Int) : Int {\n return if(par[x] == x){\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n fun same(x: Int, y: Int) : Boolean = root(x) == root(y)\n fun unite(x: Int, y: Int){\n var a = root(x)\n var b = root(y)\n if(a == b) return\n if(size[a] < size[b]){\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n fun size(x: Int) : Int = size[root(x)]\n}\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n}", "language": "Kotlin", "metadata": {"date": 1586706071, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03699/input.txt", "sample_output_relpath": "derived/input_output/data/p03699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03699/Kotlin/s748620955.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s748620955", "user_id": "u581625805"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 2147483647\nconst val LINF = 9223372036854775807L\n\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\n\nfun solve() {\n val n = nextInt()\n val s = nextIntAry(n)\n var sum = s.sum()\n s.sort()\n for (i in s.indices){\n if(sum % 10 != 0) break\n sum -= s[i]\n }\n\n println(sum)\n\n}\n\n\n\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\nfun next() = sc.next()\nfun nextInt() = sc.nextInt()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Int): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextIntAry(n: Int): IntArray {\n val ary = intAry(n)\n for (i in 0 until n) ary[i] = nextInt()\n return ary\n}\nfun nextLongAry(n: Int): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Int): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\nfun ary(n: Int, init: String = \"\") = Array(n) { init }\nfun intAry(n: Int, init: Int = 0) = IntArray(n) { init }\nfun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }\nfun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }\nfun ary2(n: Int, m: Int, init: String = \"\") = Array(n) { Array(m) { init } }\nfun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }\nfun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }\nfun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }\nfun ary3(n: Int, m: Int, k: Int, init: String = \"\") = Array(n) { Array(m) { Array(k) { init } } }\nfun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }\nfun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }\nfun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }\nfun list() = mutableListOf()\nfun intList() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun intSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\nfun Int.a() = this.toLong()\nfun Long.a() = this.toInt()\nfun IntArray.lowerBound(n: Int) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.lowerBound(n: Long) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.intLowerBound(n: Int) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double) : Int {\n var ok = this.size\n var ng = -1\n while(abs(ok - ng) > 1){\n val mid = (ok + ng) / 2\n if(this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun IntArray.cumsum(): IntArray {\n val s = intAry(this.size + 1)\n for (i in this.indices) s[i + 1] = s[i] + this[i]\n return s\n}\nfun LongArray.cumsum(): LongArray {\n val s = longAry(this.size + 1)\n for (i in this.indices) s[i + 1] = s[i] + this[i]\n return s\n}\nfun MutableMap.counting(n: Int) {\n repeat(n){\n val a = next()\n if(this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.intCounting(n: Int) {\n repeat(n){\n val a = nextInt()\n if(this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Int) {\n repeat(n){\n val a = nextLong()\n if(this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n\nfun abs(n: Int): Int = Math.abs(n)\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!\nfun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!\nfun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!\nfun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!\ntailrec fun gcd(a: Int, b: Int) : Int = if(a % b == 0) b else gcd(b, (a % b))\ntailrec fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Int, b: Int) : Int = a / gcd(a, b) * b\nfun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Int) {\n private val fac = LongArray(max)\n private val finv = LongArray(max)\n private val inv = LongArray(max)\n private val p = MOD.a()\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Int, r: Int): Long = if (n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Int, private var searched: Int = 0, private var nextIndex: Int = 0) {\n private val size = fact(n)\n private val permList = Array(size) { IntArray(n) { 0 } }\n\n private tailrec fun fact(n: Int, ans: Int = 1): Int {\n return if (n == 0) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, IntArray(n) { 0 }, Array(n) { false })\n }\n\n private fun create(num: Int, list: IntArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): IntArray = permList[nextIndex++]\n}\n\n\ndata class Node(val id: Int, var past: Int = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Int, val to: Int, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Int, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Int): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size, -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Int): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size, LINF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\nclass UnionFind(size: Int){\n private val par = IntArray(size) { it }\n private val size = IntArray(size) { 1 }\n fun root(x: Int) : Int {\n return if(par[x] == x){\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n fun same(x: Int, y: Int) : Boolean = root(x) == root(y)\n fun unite(x: Int, y: Int){\n var a = root(x)\n var b = root(y)\n if(a == b) return\n if(size[a] < size[b]){\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n fun size(x: Int) : Int = size[root(x)]\n}\n\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n if (buflen <= 0) false\n true\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03699", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 11687, "cpu_time_ms": 192, "memory_kb": 33736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s330002380", "group_id": "codeNet:p03699", "input_text": "import java.io.IOException;\nimport java.util.NoSuchElementException;\n\nfun main(args: Array) {\n val fs = FastScanner()\n val N = fs.nextInt()\n val s = IntArray(N)\n (1..N).forEach {\n s[it - 1] = fs.nextInt()\n }\n\n s.sort()\n val sum = s.sum()\n if (sum % 10 != 0) {\n println(sum)\n } else {\n val num = s.find {\n it % 10 != 0\n }\n if (num == null) {\n println(0)\n } else {\n println(sum - num)\n }\n }\n}\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\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 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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n}", "language": "Kotlin", "metadata": {"date": 1569289806, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03699/input.txt", "sample_output_relpath": "derived/input_output/data/p03699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03699/Kotlin/s330002380.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s330002380", "user_id": "u861095163"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.NoSuchElementException;\n\nfun main(args: Array) {\n val fs = FastScanner()\n val N = fs.nextInt()\n val s = IntArray(N)\n (1..N).forEach {\n s[it - 1] = fs.nextInt()\n }\n\n s.sort()\n val sum = s.sum()\n if (sum % 10 != 0) {\n println(sum)\n } else {\n val num = s.find {\n it % 10 != 0\n }\n if (num == null) {\n println(0)\n } else {\n println(sum - num)\n }\n }\n}\ninternal class FastScanner {\n private val `in` = System.`in`\n private val buffer = ByteArray(1024)\n private var ptr = 0\n private var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n try {\n buflen = `in`.read(buffer)\n } catch (e: IOException) {\n e.printStackTrace()\n }\n\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int {\n return if (hasNextByte()) buffer[ptr++].toInt() else -1\n }\n\n private fun isPrintableChar(c: Int): Boolean {\n return 33 <= c && c <= 126\n }\n\n operator fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\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 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 return if (b == -1 || !isPrintableChar(b)) {\n if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun nextDouble(): Double {\n return java.lang.Double.parseDouble(next())\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03699", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2701, "cpu_time_ms": 186, "memory_kb": 33736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s602913380", "group_id": "codeNet:p03711", "input_text": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (x, y) = listOfInt()\n val aList = listOf(1, 3, 5, 7, 8, 10, 12)\n val bList = listOf(4, 6, 9, 11)\n\n if ((x in aList && y in aList) || (x in bList && y in bList)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "language": "Kotlin", "metadata": {"date": 1565001846, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03711/input.txt", "sample_output_relpath": "derived/input_output/data/p03711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03711/Kotlin/s602913380.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602913380", "user_id": "u262403099"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.PrintWriter\nval pw = PrintWriter(System.out)\n\nfun main(args : Array) {\n func()\n pw.flush()\n}\n\nfun func() {\n val (x, y) = listOfInt()\n val aList = listOf(1, 3, 5, 7, 8, 10, 12)\n val bList = listOf(4, 6, 9, 11)\n\n if ((x in aList && y in aList) || (x in bList && y in bList)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map { it.toInt() }\n\nfun println(value : Any) {\n pw.println(value)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "sample_input": "1 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03711", "source_text": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 582, "cpu_time_ms": 244, "memory_kb": 36100}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s437524654", "group_id": "codeNet:p03713", "input_text": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val h = sc.nextInt()\n val w = sc.nextInt()\n if (h % 3 == 0 || w % 3 == 0) {\n println(\"0\")\n return\n }\n\n fun calc(a: Long, b: Long, c: Long): Long {\n val min = min(a, min(b, c))\n val max = max(a, max(b, c))\n return max - min\n }\n\n var ans = Long.MAX_VALUE\n for (w2 in 1 until w) {\n val a = h.toLong() * w2\n val h2 = h / 2\n val b = h2.toLong() * (w - w2)\n val c = (h - h2).toLong() * (w - w2)\n ans = min(ans, calc(a, b, c))\n }\n\n for (h2 in 1 until h) {\n val a = h2.toLong() * w\n val w2 = w / 2\n val b = (h - h2).toLong() * w2\n val c = (h - h2).toLong() * (w - w2)\n ans = min(ans, calc(a, b, c))\n }\n\n println(ans)\n }\n}\n\nclass MyScanner {\n private var ptr = 0\n private var l = listOf()\n\n fun next(): String {\n while (l.size <= ptr) {\n l = readLine()!!.split(' ')\n ptr = 0\n }\n return l[ptr++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun list(): List {\n ptr = l.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = list().map { s -> s.toInt() }\n fun longList() = list().map { s -> s.toLong() }\n fun doubleList() = list().map { s -> s.toDouble() }\n\n fun array() = list().toTypedArray()\n fun intArray() = intList().toIntArray()\n fun longArray() = longList().toLongArray()\n fun doubleArray() = doubleList().toDoubleArray()\n}\n", "language": "Kotlin", "metadata": {"date": 1600178371, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03713/input.txt", "sample_output_relpath": "derived/input_output/data/p03713/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03713/Kotlin/s437524654.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s437524654", "user_id": "u194412908"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import kotlin.math.max\nimport kotlin.math.min\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = MyScanner()\n val h = sc.nextInt()\n val w = sc.nextInt()\n if (h % 3 == 0 || w % 3 == 0) {\n println(\"0\")\n return\n }\n\n fun calc(a: Long, b: Long, c: Long): Long {\n val min = min(a, min(b, c))\n val max = max(a, max(b, c))\n return max - min\n }\n\n var ans = Long.MAX_VALUE\n for (w2 in 1 until w) {\n val a = h.toLong() * w2\n val h2 = h / 2\n val b = h2.toLong() * (w - w2)\n val c = (h - h2).toLong() * (w - w2)\n ans = min(ans, calc(a, b, c))\n }\n\n for (h2 in 1 until h) {\n val a = h2.toLong() * w\n val w2 = w / 2\n val b = (h - h2).toLong() * w2\n val c = (h - h2).toLong() * (w - w2)\n ans = min(ans, calc(a, b, c))\n }\n\n println(ans)\n }\n}\n\nclass MyScanner {\n private var ptr = 0\n private var l = listOf()\n\n fun next(): String {\n while (l.size <= ptr) {\n l = readLine()!!.split(' ')\n ptr = 0\n }\n return l[ptr++]\n }\n\n fun nextInt() = next().toInt()\n fun nextLong() = next().toLong()\n fun nextDouble() = next().toDouble()\n fun nextCharArray() = next().toCharArray()\n fun nextChar() = next()[0]\n\n fun list(): List {\n ptr = l.size\n return readLine()!!.split(' ')\n }\n\n fun intList() = list().map { s -> s.toInt() }\n fun longList() = list().map { s -> s.toLong() }\n fun doubleList() = list().map { s -> s.toDouble() }\n\n fun array() = list().toTypedArray()\n fun intArray() = intList().toIntArray()\n fun longArray() = longList().toLongArray()\n fun doubleArray() = doubleList().toDoubleArray()\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03713", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1908, "cpu_time_ms": 121, "memory_kb": 36552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s187487290", "group_id": "codeNet:p03713", "input_text": "\nfun main(args: Array) {\n\tvar (h, w) = readLine()!!.split(\" \").map{ it.toLong() }\n\tif (h % 3 == 0L || w % 3 == 0L) {\n\t\tprintln(0)\n\t\treturn\n\t}\n\tvar ans = Math.min(h, w)\n\tfor (i in 1..(w - 1)) {\n\t\tval a = (w - i) * h\n\t\tval b = ((h + 1) / 2) * i\n\t\tval c = (h / 2) * i\n\t\tval diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))\n\t\tans = Math.min(ans, diff)\n\t}\n\tfor (i in 1..(h - 1)) {\n\t\tval a = (h - i) * w\n\t\tval b = ((w + 1) / 2) * i\n\t\tval c = (w / 2) * i\n\t\tval diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))\n\t\tans = Math.min(ans, diff)\n\t}\n\tprintln(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1581153967, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03713/input.txt", "sample_output_relpath": "derived/input_output/data/p03713/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03713/Kotlin/s187487290.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187487290", "user_id": "u898209217"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "\nfun main(args: Array) {\n\tvar (h, w) = readLine()!!.split(\" \").map{ it.toLong() }\n\tif (h % 3 == 0L || w % 3 == 0L) {\n\t\tprintln(0)\n\t\treturn\n\t}\n\tvar ans = Math.min(h, w)\n\tfor (i in 1..(w - 1)) {\n\t\tval a = (w - i) * h\n\t\tval b = ((h + 1) / 2) * i\n\t\tval c = (h / 2) * i\n\t\tval diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))\n\t\tans = Math.min(ans, diff)\n\t}\n\tfor (i in 1..(h - 1)) {\n\t\tval a = (h - i) * w\n\t\tval b = ((w + 1) / 2) * i\n\t\tval c = (w / 2) * i\n\t\tval diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))\n\t\tans = Math.min(ans, diff)\n\t}\n\tprintln(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03713", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 614, "cpu_time_ms": 254, "memory_kb": 37844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s659948703", "group_id": "codeNet:p03721", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map{it.toInt()}\n val ps = Array(N) {\n val (a, b) = readLine()!!.split(\" \").map{it.toLong()}\n Pair(a, b)\n }\n ps.sortBy { it.first }\n\n var s = 0L\n\n for (p in ps) {\n s += p.second\n if (s >= K) {\n println(p.first)\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1577213259, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03721/input.txt", "sample_output_relpath": "derived/input_output/data/p03721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03721/Kotlin/s659948703.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s659948703", "user_id": "u183530284"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map{it.toInt()}\n val ps = Array(N) {\n val (a, b) = readLine()!!.split(\" \").map{it.toLong()}\n Pair(a, b)\n }\n ps.sortBy { it.first }\n\n var s = 0L\n\n for (p in ps) {\n s += p.second\n if (s >= K) {\n println(p.first)\n return\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 373, "cpu_time_ms": 978, "memory_kb": 80224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s640136053", "group_id": "codeNet:p03721", "input_text": "import java.io.InputStreamReader\nimport java.io.BufferedReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val MAX = 100001\n\n val(n, k) = br.readLine().split(\" \").map { it.toInt() }\n\n val table = LongArray(MAX+1)\n table[MAX] = Long.MAX_VALUE\n (0 until n).forEach {\n val(a, b) = br.readLine().split(\" \").map { it.toInt() }\n table[a] += b.toLong()\n }\n\n tailrec fun rec(acc: Long, i: Int, t: Int): Int {\n val v = acc + table[i]\n if(v >= t) return i\n return rec(v, i+1, t)\n }\n\n val ans = rec(0, 0, k)\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1567992011, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03721/input.txt", "sample_output_relpath": "derived/input_output/data/p03721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03721/Kotlin/s640136053.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s640136053", "user_id": "u217010036"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.InputStreamReader\nimport java.io.BufferedReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val MAX = 100001\n\n val(n, k) = br.readLine().split(\" \").map { it.toInt() }\n\n val table = LongArray(MAX+1)\n table[MAX] = Long.MAX_VALUE\n (0 until n).forEach {\n val(a, b) = br.readLine().split(\" \").map { it.toInt() }\n table[a] += b.toLong()\n }\n\n tailrec fun rec(acc: Long, i: Int, t: Int): Int {\n val v = acc + table[i]\n if(v >= t) return i\n return rec(v, i+1, t)\n }\n\n val ans = rec(0, 0, k)\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 585, "cpu_time_ms": 554, "memory_kb": 52064}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s528638779", "group_id": "codeNet:p03721", "input_text": "import java.io.InputStreamReader\nimport java.io.BufferedReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val MAX = 100002\n\n val(n, k) = br.readLine().split(\" \").map { it.toInt() }\n\n val table = IntArray(MAX+1)\n table[MAX] = Int.MAX_VALUE\n (0 until n).forEach {\n val(a, b) = br.readLine().split(\" \").map { it.toInt() }\n table[a] += b\n }\n\n tailrec fun rec(acc: Int, i: Int, t: Int): Int =\n if(acc >= t) i\n else rec(acc + table[i+1], i+1, t)\n\n val ans = rec(0, 0, k)\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1567990003, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03721/input.txt", "sample_output_relpath": "derived/input_output/data/p03721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03721/Kotlin/s528638779.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s528638779", "user_id": "u217010036"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.InputStreamReader\nimport java.io.BufferedReader\n\nfun main(args: Array) {\n val br = BufferedReader(InputStreamReader(System.`in`))\n val MAX = 100002\n\n val(n, k) = br.readLine().split(\" \").map { it.toInt() }\n\n val table = IntArray(MAX+1)\n table[MAX] = Int.MAX_VALUE\n (0 until n).forEach {\n val(a, b) = br.readLine().split(\" \").map { it.toInt() }\n table[a] += b\n }\n\n tailrec fun rec(acc: Int, i: Int, t: Int): Int =\n if(acc >= t) i\n else rec(acc + table[i+1], i+1, t)\n\n val ans = rec(0, 0, k)\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 550, "cpu_time_ms": 538, "memory_kb": 49836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s402090705", "group_id": "codeNet:p03721", "input_text": "fun main(args: Array) {\n val input = readLine()!!.split(\" \")\n val n=input[0].toInt()\n val k=input[1].toLong()\n val ab = (1..n).map{\n readLine()!!.split(\" \").map{it.toInt()}\n }.sortedBy { it[0] }\n\n var x=0L\n ab.forEach {\n x+=it[1]\n if(x>=k){\n println(it[0])\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1541193206, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03721/input.txt", "sample_output_relpath": "derived/input_output/data/p03721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03721/Kotlin/s402090705.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402090705", "user_id": "u914096045"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val input = readLine()!!.split(\" \")\n val n=input[0].toInt()\n val k=input[1].toLong()\n val ab = (1..n).map{\n readLine()!!.split(\" \").map{it.toInt()}\n }.sortedBy { it[0] }\n\n var x=0L\n ab.forEach {\n x+=it[1]\n if(x>=k){\n println(it[0])\n return\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 354, "cpu_time_ms": 863, "memory_kb": 84848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s781343349", "group_id": "codeNet:p03721", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map(String::toLong)\n var sum = 0L\n\n while (true) {\n val (a, b) = readLine()!!.split(\" \").map(String::toLong)\n sum += b\n if (sum >= K) {\n println(a)\n return\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1494727443, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03721/input.txt", "sample_output_relpath": "derived/input_output/data/p03721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03721/Kotlin/s781343349.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s781343349", "user_id": "u857067005"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map(String::toLong)\n var sum = 0L\n\n while (true) {\n val (a, b) = readLine()!!.split(\" \").map(String::toLong)\n sum += b\n if (sum >= K) {\n println(a)\n return\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 550, "memory_kb": 51732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s845208392", "group_id": "codeNet:p03722", "input_text": "import java.util.*\n\ndata class Edge>(val from: Int, val to: Int, val weight: T) {\n constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)\n}\n\nclass Graph>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {\n val edges = Array(n) { ArrayList>() }\n}\n\nval INF = 1e+15.toLong()\n\ninline fun >bellmanFord(g: Graph, s: Int): Triple, Array, Array> {\n val N = g.n\n val dist = Array(N) { g.inf }\n val prev = Array(N) {-1}\n\n dist[s] = g.zero\n\n for (k in 1 .. N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist[e.from] != INF && dist[e.to] > g.plus(dist[e.from], e.weight)) {\n dist[e.to] = g.plus(dist[e.from], e.weight)\n prev[e.to] = e.from\n }\n }\n }\n }\n\n val dist2 = dist.copyOf()\n for (k in 1 .. N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist2[e.from] != INF && dist2[e.to] > g.plus(dist2[e.from], e.weight)) {\n dist2[e.to] = g.plus(dist2[e.from], e.weight)\n }\n }\n }\n }\n\n val affectedByNegativeLoop = Array(N) { idx -> dist[idx] != dist2[idx] }\n\n return Triple(dist, prev, affectedByNegativeLoop)\n}\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { s -> s.toInt() }\n val g = Graph(N, 0L, INF) { a: Long, b: Long -> a + b}\n\n for (i in 1 .. M) {\n val (a, b, c) = readLine()!!.split(\" \").map {s -> s.toLong()}\n g.edges[(a - 1).toInt()].add(Edge(a - 1, b - 1, -c))\n }\n\n val (dist, prev, affectedByNegativeLoop) = bellmanFord(g, 0)\n\n if (affectedByNegativeLoop[N - 1]) {\n println(\"inf\")\n } else {\n println(-dist[N - 1])\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1571367128, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03722/input.txt", "sample_output_relpath": "derived/input_output/data/p03722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03722/Kotlin/s845208392.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845208392", "user_id": "u183530284"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*\n\ndata class Edge>(val from: Int, val to: Int, val weight: T) {\n constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)\n}\n\nclass Graph>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {\n val edges = Array(n) { ArrayList>() }\n}\n\nval INF = 1e+15.toLong()\n\ninline fun >bellmanFord(g: Graph, s: Int): Triple, Array, Array> {\n val N = g.n\n val dist = Array(N) { g.inf }\n val prev = Array(N) {-1}\n\n dist[s] = g.zero\n\n for (k in 1 .. N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist[e.from] != INF && dist[e.to] > g.plus(dist[e.from], e.weight)) {\n dist[e.to] = g.plus(dist[e.from], e.weight)\n prev[e.to] = e.from\n }\n }\n }\n }\n\n val dist2 = dist.copyOf()\n for (k in 1 .. N) {\n for (v in 0 until N) {\n for (e in g.edges[v]) {\n if (dist2[e.from] != INF && dist2[e.to] > g.plus(dist2[e.from], e.weight)) {\n dist2[e.to] = g.plus(dist2[e.from], e.weight)\n }\n }\n }\n }\n\n val affectedByNegativeLoop = Array(N) { idx -> dist[idx] != dist2[idx] }\n\n return Triple(dist, prev, affectedByNegativeLoop)\n}\n\nfun main(args: Array) {\n val (N, M) = readLine()!!.split(\" \").map { s -> s.toInt() }\n val g = Graph(N, 0L, INF) { a: Long, b: Long -> a + b}\n\n for (i in 1 .. M) {\n val (a, b, c) = readLine()!!.split(\" \").map {s -> s.toLong()}\n g.edges[(a - 1).toInt()].add(Edge(a - 1, b - 1, -c))\n }\n\n val (dist, prev, affectedByNegativeLoop) = bellmanFord(g, 0)\n\n if (affectedByNegativeLoop[N - 1]) {\n println(\"inf\")\n } else {\n println(-dist[N - 1])\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i.\nWe will play the following single-player game using this graph and a piece.\n\nInitially, the piece is placed at vertex 1, and the score of the player is set to 0.\nThe player can move the piece as follows:\n\nWhen the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.\n\nThe player can end the game only when the piece is placed at vertex N.\nThe given graph guarantees that it is possible to traverse from vertex 1 to vertex N.\n\nWhen the player acts optimally to maximize the score at the end of the game, what will the score be?\nIf it is possible to increase the score indefinitely, print inf.\n\nConstraints\n\n2≤N≤1000\n\n1≤M≤min(N(N-1),2000)\n\n1≤a_i,b_i≤N (1≤i≤M)\n\na_i≠b_i (1≤i≤M)\n\na_i≠a_j or b_i≠b_j (1≤i 1 && a * i % b == a % b) {\n break\n }\n if (a * i % b == c) {\n ans = true\n break\n }\n i++\n }\n\n println(if (ans) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1594153122, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03730/input.txt", "sample_output_relpath": "derived/input_output/data/p03730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03730/Kotlin/s613846095.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s613846095", "user_id": "u863309603"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main() {\n val (a, b, c) = readLine()!!.split(' ').map { it.toInt() }\n var ans = false\n\n var i = 1\n while (true) {\n if (i > 1 && a * i % b == a % b) {\n break\n }\n if (a * i % b == c) {\n ans = true\n break\n }\n i++\n }\n\n println(if (ans) \"YES\" else \"NO\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "sample_input": "7 5 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03730", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 115, "memory_kb": 36276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s227038642", "group_id": "codeNet:p03730", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n\n val alreadyExists = hashMapOf()\n 1.until(101).forEach loop@{\n val r = (a * it) % b\n if (r == c) {\n println(\"Yes\")\n return\n }\n alreadyExists[r]?.let {\n return@loop\n }\n alreadyExists[r] = true\n }\n println(\"No\")\n}", "language": "Kotlin", "metadata": {"date": 1589503970, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03730/input.txt", "sample_output_relpath": "derived/input_output/data/p03730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03730/Kotlin/s227038642.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s227038642", "user_id": "u979429407"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()?.split(\" \")?.map(String::toInt) ?: return\n\n val alreadyExists = hashMapOf()\n 1.until(101).forEach loop@{\n val r = (a * it) % b\n if (r == c) {\n println(\"Yes\")\n return\n }\n alreadyExists[r]?.let {\n return@loop\n }\n alreadyExists[r] = true\n }\n println(\"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "sample_input": "7 5 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03730", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 418, "cpu_time_ms": 250, "memory_kb": 37872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s468422036", "group_id": "codeNet:p03732", "input_text": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nval MAX_WEIGHT: Int = 400\ndata class Item(val w: Int, val v: Long)\nfun main(args: Array) {\n\tval (n, w) = readListOfInt()\n\tval items = Array(n) { Item(0, 0) }\n\tfor(i in 0 until n) {\n\t\tval (cw, v) = readListOfInt()\n\t\titems[i] = Item(cw, v.toLong())\n\t}\n\tval minWeight = items.minBy { it.w }?.w?: 0\n\tfor(i in 0 until n) {\n\t\tval oldItem = items[i]\n\t\titems[i] = Item(oldItem.w - minWeight + 1, oldItem.v)\n\t}\n\t// dp[いくつ目まで選んだか][重さの和(400)] = 価値\n\t// w1を1として 4まで用意する\n\tval dp = Array(n+1) { Array(MAX_WEIGHT + 1) { 0L } }\n\tfor(i in 1 .. n) {\n\t\tval item = items[i-1]\n\t\tfor(j in 0 .. MAX_WEIGHT) {\n\t\t\tdp[i][j] = Math.max(dp[i][j], dp[i-1][j])\n\t\t\tif(j + item.w <= MAX_WEIGHT) {\n\t\t\t\tdp[i][j + item.w] = Math.max(dp[i][j + item.w], dp[i-1][j] + item.v)\n\t\t\t}\n\t\t}\n\t}\n\tval maxValue = dp[n][Math.max(0, w-minWeight)]\n\tprintln(maxValue)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "language": "Kotlin", "metadata": {"date": 1586917317, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03732.html", "problem_id": "p03732", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03732/input.txt", "sample_output_relpath": "derived/input_output/data/p03732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03732/Kotlin/s468422036.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s468422036", "user_id": "u026686258"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.PrintWriter\nimport java.util.*\nimport java.math.*\nimport java.lang.*\nimport kotlin.comparisons.*\n\nval pw = PrintWriter(System.out)\nval MOD: Long = (1e+9 + 7).toLong()\n\nval MAX_WEIGHT: Int = 400\ndata class Item(val w: Int, val v: Long)\nfun main(args: Array) {\n\tval (n, w) = readListOfInt()\n\tval items = Array(n) { Item(0, 0) }\n\tfor(i in 0 until n) {\n\t\tval (cw, v) = readListOfInt()\n\t\titems[i] = Item(cw, v.toLong())\n\t}\n\tval minWeight = items.minBy { it.w }?.w?: 0\n\tfor(i in 0 until n) {\n\t\tval oldItem = items[i]\n\t\titems[i] = Item(oldItem.w - minWeight + 1, oldItem.v)\n\t}\n\t// dp[いくつ目まで選んだか][重さの和(400)] = 価値\n\t// w1を1として 4まで用意する\n\tval dp = Array(n+1) { Array(MAX_WEIGHT + 1) { 0L } }\n\tfor(i in 1 .. n) {\n\t\tval item = items[i-1]\n\t\tfor(j in 0 .. MAX_WEIGHT) {\n\t\t\tdp[i][j] = Math.max(dp[i][j], dp[i-1][j])\n\t\t\tif(j + item.w <= MAX_WEIGHT) {\n\t\t\t\tdp[i][j + item.w] = Math.max(dp[i][j + item.w], dp[i-1][j] + item.v)\n\t\t\t}\n\t\t}\n\t}\n\tval maxValue = dp[n][Math.max(0, w-minWeight)]\n\tprintln(maxValue)\n\tpw.flush()\n}\n\n/****** Declared Functions and Data Structures ******/\n// IO\nfun read() = readLine()!!\nfun readInt() = read().toInt()\nfun readLong() = read().toLong()\nfun readDouble() = read().toDouble()\nfun readListOfString() = read().split(\" \")\nfun readListOfInt() = readListOfString().map { it.toInt() }\nfun readListOfLong() = readListOfString().map { it.toLong() }\nfun readListOfDouble() = readListOfString().map { it.toDouble() }\n\nfun Double.format(digits: Int) = String.format(\"%.${digits}f\", this)\nfun Float.format(digits: Int) = String.format(\"%.${digits}f\", this)\n\nfun print(value: Any) { pw.print(value) }\nfun println(value : Any) { pw.println(value) }\n\n// Extensions\nfun List.toBuckets(): Map\n\t= this.groupBy { it }.mapValues { it.value.size }\n\nfun> List.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element >= this[mid]) { \n\t\t\tl = mid + 1\n\t\t} else {\n\t\t\tr = mid\n\t\t}\n\t}\n\treturn l\n}\n\nfun> List.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {\n\tvar l = fromIndex\n\tvar r = toIndex\n\twhile(l < r) {\n\t\tval mid = (l+r) / 2\n\t\tif(element <= this[mid]) { \n\t\t\tr = mid\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t}\n\treturn r \n}\n\nfun Map.toMutableMap(): MutableMap = HashMap(this)\n\n// Util Functions\nfun Long.makeDivisors(): List {\n\tval divisors = mutableListOf()\n\tfor(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {\n\t\tif(this % i == 0L) {\n\t\t\tdivisors.add(i)\n\t\t\tif(i != this/i) {\n\t\t\t\tdivisors.add(this/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn divisors.distinct().sorted()\n}\n\nfun Long.isPrime(): Boolean {\n\tif(this==1L) return false\n\tfor(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {\n\t\tif(this % i == 0L && this != i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\nfun permutations(src: List): List> {\n\tif(src.size == 1) return listOf(src)\n\tval perms = mutableListOf>()\n\tval insertElement = src[0]\n\tpermutations(src.drop(1)).forEach { perm ->\n\t\tfor(i in 0..perm.size) {\n\t\t\tval newPerm = perm.toMutableList()\n\t\t\tnewPerm.add(i, insertElement)\n\t\t\tperms.add(newPerm.toList())\n\t\t}\n\t}\n\treturn perms\n}\n\n// return nCr, if you want nCr, please access v[n][r]\nfun combinations(n: Long): List> {\n\tval v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()\n\tfor(i in 0 until v.size) {\n\t\tv[i][0] = 1L\n\t\tv[i][i] = 1L\n\t}\n\tfor(i in 0 until v.size) {\n\t\tfor(j in 1 until i) {\n\t\t\tv[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD\n\t\t}\n\t}\n\treturn v.map { it.toList() }.toList()\n}\n\nfun repeatedModPow(a: Long, n: Long, mod: Long): Long = \n\twhen {\n\t\tn == 1L -> a % mod\n\t\tn % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod\n\t\telse -> {\n\t\t\tval tmp = repeatedModPow(a, n / 2L, mod)\n\t\t\t(tmp * tmp) % mod\n\t\t}\n\t}\n\n// return nCr % MOD\nfun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {\n\tvar ret = 1L\n\tval min = Math.min(k, n-k)\n\t// まず分母の計算\n\tfor(i in n downTo (n - min + 1)) {\n\t\tret = ret * i % mod\n\t}\n\tfor(i in min downTo 1) {\n\t\tret = ret * repeatedModPow(i, (mod - 2L), mod) % mod\n\t}\n\treturn ret\n}\n\n// return nCr % MOD\nfun modnCk(n: Int, k: Int, mod: Long): Long {\n\tval factorials = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval inverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tval factorialInverses = Array(n+1) { 0L }.apply {\n\t\tthis[0] = 1L\n\t\tif(this.size > 1) this[1] = 1L\n\t}\n\tfor(i in 2 .. n) {\n\t\tfactorials[i] = (factorials[i-1] * i.toLong() % mod)\n\t\tinverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)\n\t\tfactorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)\n\t}\n\n\treturn factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod\n}\n\n// should be a >= b\nfun gcd(a: Long, b: Long): Long = \n\tif(b == 0L) a else gcd(b, a % b)\n\n// shoud be a >= b\nfun lcm(a: Long, b: Long): Long = \n\ta / gcd(a, b) * b\n\nfun sumDigits(num_: Long): Long {\n\tvar num = num_\n\tvar rtn: Long = 0\n\twhile(num != 0.toLong()) {\n\t\tval tmp = num % 10\n\t\trtn += tmp\n\t\tnum /= 10\n\t}\n\treturn rtn\n}\n\nfun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)\n\n// Data Structures\n\nclass UnionFind(private val n: Int) {\n\tprivate val parent: Array = Array(n) { 0 }\n\tprivate val rank: Array = Array(n) { 0 }\n\tprivate val size: Array = Array(n) { 0 }\n\n\tinit {\n\t\tfor(i in 0 until n) {\n\t\t\tparent[i] = i\n\t\t\trank[i] = 1\n\t\t\tsize[i] = 1\n\t\t}\n\t}\n\n\tfun union(u: Int, v: Int) {\n\t\tvar x = root(u)\n\t\tvar y = root(v)\n\t\tif(x != y) {\n\t\t\tif(rank[y] < rank[x]) {\n\t\t\t\tval tmp = y \n\t\t\t\ty = x\n\t\t\t\tx = tmp \n\t\t\t}\n\t\t\tparent[x] = y\n\t\t\trank[y] += rank[x]\n\t\t\trank[x] = -1\n\t\t\tval totalSize = size[x] + size[y]\n\t\t\tsize[x] = totalSize\n\t\t\tsize[y] = totalSize\n\t\t}\n\t}\n\n\tfun root(u: Int): Int {\n\t\tvar x = u\n\t\twhile(parent[x] != x) {\n\t\t\tx = parent[x]\n\t\t}\n\t\treturn x \n\t}\n\n\tfun size(u: Int): Int = size[root(u)]\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03732", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5978, "cpu_time_ms": 290, "memory_kb": 40908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s861927700", "group_id": "codeNet:p03737", "input_text": "import java.io.PrintWriter\nimport kotlin.math.pow\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Int.pow(n: Int) = pow(n.toLong())\nfun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\nfun Long.pow(n: Int) = pow(n.toLong())\nfun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (s1, s2, s3) = nextList()\n println(\"${s1[0].toUpperCase()}${s2[0].toUpperCase()}${s3[0].toUpperCase()}\")\n}", "language": "Kotlin", "metadata": {"date": 1595552720, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/Kotlin/s861927700.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s861927700", "user_id": "u860789370"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.io.PrintWriter\nimport kotlin.math.pow\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Int.pow(n: Int) = pow(n.toLong())\nfun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\nfun Long.pow(n: Int) = pow(n.toLong())\nfun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (s1, s2, s3) = nextList()\n println(\"${s1[0].toUpperCase()}${s2[0].toUpperCase()}${s3[0].toUpperCase()}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1183, "cpu_time_ms": 118, "memory_kb": 35836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s880458725", "group_id": "codeNet:p03738", "input_text": "\nfun main(args:Array) {\n val num = (1..2).map { readLine()!! }\n val maxLen = num.map { it.length }.max()!!\n val (a,b) = num.map { it.padStart(maxLen, '0') }\n if(a > b) {\n println(\"GREATER\")\n } else if(a < b) {\n println(\"LESS\")\n } else {\n println(\"EQUAL\")\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1594843271, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03738/input.txt", "sample_output_relpath": "derived/input_output/data/p03738/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03738/Kotlin/s880458725.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s880458725", "user_id": "u269969976"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "\nfun main(args:Array) {\n val num = (1..2).map { readLine()!! }\n val maxLen = num.map { it.length }.max()!!\n val (a,b) = num.map { it.padStart(maxLen, '0') }\n if(a > b) {\n println(\"GREATER\")\n } else if(a < b) {\n println(\"LESS\")\n } else {\n println(\"EQUAL\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "sample_input": "36\n24\n"}, "reference_outputs": ["GREATER\n"], "source_document_id": "p03738", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 120, "memory_kb": 36496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s837239965", "group_id": "codeNet:p03739", "input_text": "import java.io.*\nimport java.util.*\n\nfun solve(n: Int, a: LongArray){\n var ans1 = 0L\n var ret1 = 0L\n var ans2 = 0L\n var ret2 = 0L\n for(i in 0 until n){\n ret1 += a[i]\n ret2 += a[i]\n if(i % 2 == 0 && ret1 <= 0){\n ans1 -= ret1 - 1\n ret1 = 1L\n }else if(i % 2 == 1 && ret1 >= 0){\n ans1 += ret1 + 1\n ret1 = -1L\n }\n if(i % 2 == 0 && ret2 >=0){\n ans2 += ret2 + 1\n ret2 = -1L\n }else if(i % 2 == 1 && ret2 <= 0){\n ans2 -= ret2 - 1\n ret2 = 1L\n }\n }\n println(Math.min(ans1, ans2))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val n = sc.next().toInt()\n val a = LongArray(n)\n for (i in 0 until n) {\n a[i] = sc.next().toLong()\n }\n solve(n, a)\n}\n\n", "language": "Kotlin", "metadata": {"date": 1567366165, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03739.html", "problem_id": "p03739", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03739/input.txt", "sample_output_relpath": "derived/input_output/data/p03739/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03739/Kotlin/s837239965.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s837239965", "user_id": "u329232967"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\n\nfun solve(n: Int, a: LongArray){\n var ans1 = 0L\n var ret1 = 0L\n var ans2 = 0L\n var ret2 = 0L\n for(i in 0 until n){\n ret1 += a[i]\n ret2 += a[i]\n if(i % 2 == 0 && ret1 <= 0){\n ans1 -= ret1 - 1\n ret1 = 1L\n }else if(i % 2 == 1 && ret1 >= 0){\n ans1 += ret1 + 1\n ret1 = -1L\n }\n if(i % 2 == 0 && ret2 >=0){\n ans2 += ret2 + 1\n ret2 = -1L\n }else if(i % 2 == 1 && ret2 <= 0){\n ans2 -= ret2 - 1\n ret2 = 1L\n }\n }\n println(Math.min(ans1, ans2))\n return\n}\n\n\nfun main(args: Array) {\n fun StringArray(size: Int, init: (Int) -> String = { \"\\u0000\" }): Array {\n return Array(size, init)\n }\n class Scanner(stream: InputStream) {\n private val reader = BufferedInputStream(stream).bufferedReader()\n private var st: StringTokenizer? = null\n fun next(): String {\n while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())\n return st!!.nextToken()\n }\n }\n val sc = Scanner(System.`in`)\n val n = sc.next().toInt()\n val a = LongArray(n)\n for (i in 0 until n) {\n a[i] = sc.next().toLong()\n }\n solve(n, a)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "sample_input": "4\n1 -3 1 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03739", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1325, "cpu_time_ms": 344, "memory_kb": 44164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s984277045", "group_id": "codeNet:p03745", "input_text": "fun main(arr: Array) {\n val n = readLine()!!.toInt()\n val r = readLine()!!.split(\" \").map { it.toLong() }\n val fixed = mutableListOf(r.first())\n for(i in (1 until n)) {\n if(r[i] != fixed.last()) {\n fixed.add(r[i])\n }\n }\n var isBigger = fixed[0] <= fixed[1]\n var ans = 1\n var idx = 1\n if(fixed.size >= 2) {\n while (idx < fixed.size) {\n if(isBigger) {\n if(fixed[idx-1] < fixed[idx]) {\n idx++\n continue\n }\n } else {\n if(fixed[idx-1] > fixed[idx]) {\n idx++\n continue\n }\n }\n if(idx < fixed.size - 1) {\n isBigger = fixed[idx] <= fixed[idx+1]\n }\n ans++\n idx+=1\n }\n }\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1600608262, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03745.html", "problem_id": "p03745", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03745/input.txt", "sample_output_relpath": "derived/input_output/data/p03745/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03745/Kotlin/s984277045.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s984277045", "user_id": "u269969976"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(arr: Array) {\n val n = readLine()!!.toInt()\n val r = readLine()!!.split(\" \").map { it.toLong() }\n val fixed = mutableListOf(r.first())\n for(i in (1 until n)) {\n if(r[i] != fixed.last()) {\n fixed.add(r[i])\n }\n }\n var isBigger = fixed[0] <= fixed[1]\n var ans = 1\n var idx = 1\n if(fixed.size >= 2) {\n while (idx < fixed.size) {\n if(isBigger) {\n if(fixed[idx-1] < fixed[idx]) {\n idx++\n continue\n }\n } else {\n if(fixed[idx-1] > fixed[idx]) {\n idx++\n continue\n }\n }\n if(idx < fixed.size - 1) {\n isBigger = fixed[idx] <= fixed[idx+1]\n }\n ans++\n idx+=1\n }\n }\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nEach A_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "sample_input": "6\n1 2 3 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03745", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nEach A_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 883, "cpu_time_ms": 333, "memory_kb": 57900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s075329402", "group_id": "codeNet:p03759", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n println(if (b - a == c - b) \"YES\" else \"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1579635845, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03759.html", "problem_id": "p03759", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03759/input.txt", "sample_output_relpath": "derived/input_output/data/p03759/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03759/Kotlin/s075329402.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075329402", "user_id": "u088342491"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toInt() }\n println(if (b - a == c - b) \"YES\" else \"NO\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right.\nWe will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b.\n\nDetermine whether the arrangement of the poles is beautiful.\n\nConstraints\n\n1 \\leq a,b,c \\leq 100\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint YES if the arrangement of the poles is beautiful; print NO otherwise.\n\nSample Input 1\n\n2 4 6\n\nSample Output 1\n\nYES\n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\nSample Input 2\n\n2 5 6\n\nSample Output 2\n\nNO\n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\nSample Input 3\n\n3 2 1\n\nSample Output 3\n\nYES\n\nSince 1-2 = 2-3, this arrangement of poles is beautiful.", "sample_input": "2 4 6\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03759", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right.\nWe will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b.\n\nDetermine whether the arrangement of the poles is beautiful.\n\nConstraints\n\n1 \\leq a,b,c \\leq 100\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint YES if the arrangement of the poles is beautiful; print NO otherwise.\n\nSample Input 1\n\n2 4 6\n\nSample Output 1\n\nYES\n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\nSample Input 2\n\n2 5 6\n\nSample Output 2\n\nNO\n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\nSample Input 3\n\n3 2 1\n\nSample Output 3\n\nYES\n\nSince 1-2 = 2-3, this arrangement of poles is beautiful.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 235, "memory_kb": 37936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s808883405", "group_id": "codeNet:p03763", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val c = IntArray(26) { Int.MAX_VALUE }\n for (i in 1..n) {\n for ((j, z) in count(readLine()!!).withIndex()) c[j] = Math.min(c[j], z)\n }\n for ((i, q) in c.withIndex()) print(('a' + i).toString().repeat(q))\n println()\n}\n\nfun count(s: String): IntArray {\n val res = IntArray(26)\n s.forEach { res[it - 'a']++ }\n return res\n}", "language": "Kotlin", "metadata": {"date": 1491700168, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03763.html", "problem_id": "p03763", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03763/input.txt", "sample_output_relpath": "derived/input_output/data/p03763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03763/Kotlin/s808883405.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808883405", "user_id": "u030874863"}, "prompt_components": {"gold_output": "aac\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val c = IntArray(26) { Int.MAX_VALUE }\n for (i in 1..n) {\n for ((j, z) in count(readLine()!!).withIndex()) c[j] = Math.min(c[j], z)\n }\n for ((i, q) in c.withIndex()) print(('a' + i).toString().repeat(q))\n println()\n}\n\nfun count(s: String): IntArray {\n val res = IntArray(26)\n s.forEach { res[it - 'a']++ }\n return res\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\n\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.\n\nFind the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.\nIf there are multiple such strings, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq n \\leq 50\n\n1 \\leq |S_i| \\leq 50 for every i = 1, ..., n.\n\nS_i consists of lowercase English letters (a - z) for every i = 1, ..., n.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nS_1\n...\nS_n\n\nOutput\n\nPrint the lexicographically smallest string among the longest strings that satisfy the condition.\nIf the answer is an empty string, print an empty line.\n\nSample Input 1\n\n3\ncbaa\ndaacc\nacacac\n\nSample Output 1\n\naac\n\nThe strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.\nAmong them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.\n\nSample Input 2\n\n3\na\naa\nb\n\nSample Output 2\n\nThe answer is an empty string.", "sample_input": "3\ncbaa\ndaacc\nacacac\n"}, "reference_outputs": ["aac\n"], "source_document_id": "p03763", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\n\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.\n\nFind the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.\nIf there are multiple such strings, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq n \\leq 50\n\n1 \\leq |S_i| \\leq 50 for every i = 1, ..., n.\n\nS_i consists of lowercase English letters (a - z) for every i = 1, ..., n.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nS_1\n...\nS_n\n\nOutput\n\nPrint the lexicographically smallest string among the longest strings that satisfy the condition.\nIf the answer is an empty string, print an empty line.\n\nSample Input 1\n\n3\ncbaa\ndaacc\nacacac\n\nSample Output 1\n\naac\n\nThe strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.\nAmong them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.\n\nSample Input 2\n\n3\na\naa\nb\n\nSample Output 2\n\nThe answer is an empty string.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 416, "cpu_time_ms": 321, "memory_kb": 28028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s887916636", "group_id": "codeNet:p03767", "input_text": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }.sortedDescending()\n\n var sum = 0L\n for (i in 0 until n) {\n sum += aa[2*i+1]\n }\n\n println(sum)\n}", "language": "Kotlin", "metadata": {"date": 1573988197, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03767.html", "problem_id": "p03767", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03767/input.txt", "sample_output_relpath": "derived/input_output/data/p03767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03767/Kotlin/s887916636.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s887916636", "user_id": "u262403099"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "fun main(args : Array) {\n val n = readLine()!!.toInt()\n val aa = readLine()!!.split(\" \").map { it.toInt() }.sortedDescending()\n\n var sum = 0L\n for (i in 0 until n) {\n sum += aa[2*i+1]\n }\n\n println(sum)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "sample_input": "2\n5 2 8 5 1 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 851, "memory_kb": 83044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s896918593", "group_id": "codeNet:p03769", "input_text": "import java.io.InputStream\nimport java.math.BigDecimal\nimport java.math.BigInteger\nimport java.util.*\n\nfun main(args: Array) = input.run {\n var n = nextInt()\n var x = 1\n val ans = ArrayList()\n while (n > 0) {\n ans += x\n var p = 1\n while (p <= n) {\n ans += x\n n -= p\n p *= 2\n }\n x++\n }\n println(ans.size)\n println(ans.joinToString(\" \"))\n}\n\nval input = FastScanner()\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun next(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n fun nextDouble() = next()?.toDouble() ?: 0.0\n fun nextBigInteger(): BigInteger = next()?.toBigInteger() ?: BigInteger.ZERO\n fun nextBigDecimal(): BigDecimal = next()?.toBigDecimal() ?: BigDecimal.ZERO\n\n fun nextInts(n: Int) = IntArray(n) { nextInt() }\n fun nextLongs(n: Int) = LongArray(n) { nextLong() }\n fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\n fun nextBigIntegers(n: Int) = Array(n) { nextBigInteger() }\n fun nextBigDecimals(n: Int) = Array(n) { nextBigDecimal() }\n\n fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\n fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\n fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\n fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }\n fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1491101355, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03769.html", "problem_id": "p03769", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03769/input.txt", "sample_output_relpath": "derived/input_output/data/p03769/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03769/Kotlin/s896918593.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s896918593", "user_id": "u110651993"}, "prompt_components": {"gold_output": "4\n1 1 1 1\n", "input_to_evaluate": "import java.io.InputStream\nimport java.math.BigDecimal\nimport java.math.BigInteger\nimport java.util.*\n\nfun main(args: Array) = input.run {\n var n = nextInt()\n var x = 1\n val ans = ArrayList()\n while (n > 0) {\n ans += x\n var p = 1\n while (p <= n) {\n ans += x\n n -= p\n p *= 2\n }\n x++\n }\n println(ans.size)\n println(ans.joinToString(\" \"))\n}\n\nval input = FastScanner()\n\nfun String.toBigInteger() = BigInteger(this)\nfun String.toBigDecimal() = BigDecimal(this)\n\nclass FastScanner(private val input: InputStream = System.`in`) {\n private val sb = StringBuilder()\n private val buffer = ByteArray(4096)\n private var pos = 0\n private var size = 0\n\n fun next(): String? {\n var c = skipWhitespace()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n do {\n append(c.toChar())\n c = read()\n } while (c > ' '.toInt())\n\n toString()\n }\n }\n\n fun nextLine(): String? {\n var c = read()\n if (c < 0) return null\n\n return sb.run {\n setLength(0)\n\n while (c >= 0 && c != '\\n'.toInt()) {\n append(c.toChar())\n c = read()\n }\n\n toString()\n }\n }\n\n fun nextLong(): Long {\n var c = skipWhitespace()\n\n val sign = if (c == '-'.toInt()) {\n c = read()\n -1\n } else 1\n\n var ans = 0L\n\n while (c > ' '.toInt()) {\n ans = ans * 10 + c - '0'.toInt()\n c = read()\n }\n\n return sign * ans\n }\n\n fun nextInt() = nextLong().toInt()\n fun nextDouble() = next()?.toDouble() ?: 0.0\n fun nextBigInteger(): BigInteger = next()?.toBigInteger() ?: BigInteger.ZERO\n fun nextBigDecimal(): BigDecimal = next()?.toBigDecimal() ?: BigDecimal.ZERO\n\n fun nextInts(n: Int) = IntArray(n) { nextInt() }\n fun nextLongs(n: Int) = LongArray(n) { nextLong() }\n fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }\n fun nextBigIntegers(n: Int) = Array(n) { nextBigInteger() }\n fun nextBigDecimals(n: Int) = Array(n) { nextBigDecimal() }\n\n fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }\n fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }\n fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }\n fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }\n fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }\n\n private fun skipWhitespace(): Int {\n while (true) {\n val c = read()\n if (c > ' '.toInt() || c < 0) return c\n }\n }\n\n private fun read(): Int {\n while (pos >= size) {\n if (size < 0) return -1\n size = input.read(buffer, 0, buffer.size)\n pos = 0\n }\n return buffer[pos++].toInt()\n }\n}\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nWe will call a string x good if it satisfies the following condition:\n\nCondition: x can be represented as a concatenation of two copies of another string y of length at least 1.\n\nFor example, aa and bubobubo are good; an empty string, a, abcabcabc and abba are not good.\n\nEagle and Owl created a puzzle on good strings.\nFind one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem.\n\n1 ≤ |s| ≤ 200\n\nEach character of s is one of the 100 characters represented by the integers 1 through 100.\n\nAmong the 2^{|s|} subsequences of s, exactly N are good strings.\n\nConstraints\n\n1 ≤ N ≤ 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIn the first line, print |s|, the length of s.\nIn the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n1 1 1 1\n\nThere are two good strings that appear as subsequences of s: (1,1) and (1,1,1,1). There are six occurrences of (1,1) and one occurrence of (1,1,1,1), for a total of seven.\n\nSample Input 2\n\n299\n\nSample Output 2\n\n23\n32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10", "sample_input": "7\n"}, "reference_outputs": ["4\n1 1 1 1\n"], "source_document_id": "p03769", "source_text": "Score : 1000 points\n\nProblem Statement\n\nWe will call a string x good if it satisfies the following condition:\n\nCondition: x can be represented as a concatenation of two copies of another string y of length at least 1.\n\nFor example, aa and bubobubo are good; an empty string, a, abcabcabc and abba are not good.\n\nEagle and Owl created a puzzle on good strings.\nFind one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem.\n\n1 ≤ |s| ≤ 200\n\nEach character of s is one of the 100 characters represented by the integers 1 through 100.\n\nAmong the 2^{|s|} subsequences of s, exactly N are good strings.\n\nConstraints\n\n1 ≤ N ≤ 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIn the first line, print |s|, the length of s.\nIn the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n1 1 1 1\n\nThere are two good strings that appear as subsequences of s: (1,1) and (1,1,1,1). There are six occurrences of (1,1) and one occurrence of (1,1,1,1), for a total of seven.\n\nSample Input 2\n\n299\n\nSample Output 2\n\n23\n32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2977, "cpu_time_ms": 232, "memory_kb": 21544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s362631971", "group_id": "codeNet:p03775", "input_text": "fun main(args: Array) {\n\n val n = readLine()!!.toLong()\n\n var result = Int.MAX_VALUE\n\n loop@ for (i in 1..n) {\n\n val b = n / i\n if (i > b) {\n break@loop\n }\n\n if (n % i == 0L) {\n // 約数でこのときのiと商をペアの配列として確保\n val ilen = cntDigits(i)\n val blen = cntDigits(b)\n\n val fResult = if (ilen < blen) blen else ilen\n // kotlinのデータ型変換はtoXXXで良いのか???\n if (result > fResult) result = fResult\n }\n }\n\n println(result)\n}\n\n// toString.lengthで桁数を求めてみたが、性能が間に合わず???\n// kotlinでメソッドの引数を変更したときどうする???\n// 桁数算出メソッドを作成したが -> NG 実行時間ほぼ同じ\nfun cntDigits(num: Long): Int {\n\n var digits = 0\n var target = num\n\n while (target > 0) {\n target /= 10\n digits++\n }\n return digits\n}", "language": "Kotlin", "metadata": {"date": 1593724032, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03775/input.txt", "sample_output_relpath": "derived/input_output/data/p03775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03775/Kotlin/s362631971.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s362631971", "user_id": "u048507231"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n\n val n = readLine()!!.toLong()\n\n var result = Int.MAX_VALUE\n\n loop@ for (i in 1..n) {\n\n val b = n / i\n if (i > b) {\n break@loop\n }\n\n if (n % i == 0L) {\n // 約数でこのときのiと商をペアの配列として確保\n val ilen = cntDigits(i)\n val blen = cntDigits(b)\n\n val fResult = if (ilen < blen) blen else ilen\n // kotlinのデータ型変換はtoXXXで良いのか???\n if (result > fResult) result = fResult\n }\n }\n\n println(result)\n}\n\n// toString.lengthで桁数を求めてみたが、性能が間に合わず???\n// kotlinでメソッドの引数を変更したときどうする???\n// 桁数算出メソッドを作成したが -> NG 実行時間ほぼ同じ\nfun cntDigits(num: Long): Int {\n\n var digits = 0\n var target = num\n\n while (target > 0) {\n target /= 10\n digits++\n }\n return digits\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 992, "cpu_time_ms": 98, "memory_kb": 34560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s754075404", "group_id": "codeNet:p03775", "input_text": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n if (isPrime(n)) {\n println(\"$n\".length.toString())\n return\n }\n val primes = mutableListOf()\n var i = 0\n var prime = generatePrime(i)\n var remain = n\n while (remain != 1L) {\n if (isPrime(remain)) {\n primes.add(remain)\n remain = 1L\n }\n if (remain % prime == 0L) {\n remain /= prime\n primes.add(prime)\n } else {\n i++\n prime = generatePrime(i)\n }\n }\n var a = 1L\n var b = 1L\n primes.sortedDescending().forEach {\n if (a > b) {\n b *= it\n } else {\n a *= it\n }\n }\n val length = Math.max(a.toString().length, b.toString().length)\n println(length.toString())\n}\n\nval memo = hashMapOf()\nfun generatePrime(index: Int): Long {\n if (index == 0) {\n return 2\n }\n if (index == 1) {\n return 3\n }\n memo[index]?.let {\n return it\n }\n val prev = generatePrime(index - 1)\n var next = prev + 2\n var i = 0\n var prime = 0L\n var l = Math.sqrt(next.toDouble()).toLong()\n while (i < index - 1 && l > prime) {\n prime = generatePrime(i++)\n if (next % prime == 0L) {\n next += 2\n i = 1\n l = Math.sqrt(next.toDouble()).toLong()\n }\n }\n memo[index] = next\n return next\n}\n\nfun isPrime(candidate: Long): Boolean {\n var i = 0\n var prime = 0L\n val l = Math.sqrt(candidate.toDouble()).toLong()\n while (l > prime) {\n prime = generatePrime(i++)\n if (candidate % prime == 0L) {\n return false\n }\n }\n return true\n}\n", "language": "Kotlin", "metadata": {"date": 1590854268, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03775/input.txt", "sample_output_relpath": "derived/input_output/data/p03775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03775/Kotlin/s754075404.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s754075404", "user_id": "u979429407"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()?.toLong() ?: return\n if (isPrime(n)) {\n println(\"$n\".length.toString())\n return\n }\n val primes = mutableListOf()\n var i = 0\n var prime = generatePrime(i)\n var remain = n\n while (remain != 1L) {\n if (isPrime(remain)) {\n primes.add(remain)\n remain = 1L\n }\n if (remain % prime == 0L) {\n remain /= prime\n primes.add(prime)\n } else {\n i++\n prime = generatePrime(i)\n }\n }\n var a = 1L\n var b = 1L\n primes.sortedDescending().forEach {\n if (a > b) {\n b *= it\n } else {\n a *= it\n }\n }\n val length = Math.max(a.toString().length, b.toString().length)\n println(length.toString())\n}\n\nval memo = hashMapOf()\nfun generatePrime(index: Int): Long {\n if (index == 0) {\n return 2\n }\n if (index == 1) {\n return 3\n }\n memo[index]?.let {\n return it\n }\n val prev = generatePrime(index - 1)\n var next = prev + 2\n var i = 0\n var prime = 0L\n var l = Math.sqrt(next.toDouble()).toLong()\n while (i < index - 1 && l > prime) {\n prime = generatePrime(i++)\n if (next % prime == 0L) {\n next += 2\n i = 1\n l = Math.sqrt(next.toDouble()).toLong()\n }\n }\n memo[index] = next\n return next\n}\n\nfun isPrime(candidate: Long): Boolean {\n var i = 0\n var prime = 0L\n val l = Math.sqrt(candidate.toDouble()).toLong()\n while (l > prime) {\n prime = generatePrime(i++)\n if (candidate % prime == 0L) {\n return false\n }\n }\n return true\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1729, "cpu_time_ms": 2111, "memory_kb": 110852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s520929360", "group_id": "codeNet:p03775", "input_text": "fun main(args: Array) {\n val N = readLine()!!.toLong()\n\n\n val sqrtN = Math.sqrt(N.toDouble()).toLong()\n\n // log_10(x)\n fun digits(x: Long) : Int {\n var num = x\n var count = 0\n while (num > 0) {\n num /= 10\n count++\n }\n return count\n }\n\n fun F(A: Long, B: Long) : Int {\n return Math.max(digits(A), digits(B))\n }\n\n var answer = Int.MAX_VALUE\n // O(N^0.5 * log_10 N)\n (1..sqrtN).forEach { A ->\n if (N % A == 0L) {\n val B = N / A\n answer = Math.min(answer, F(A, B))\n }\n }\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1568229100, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03775/input.txt", "sample_output_relpath": "derived/input_output/data/p03775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03775/Kotlin/s520929360.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s520929360", "user_id": "u861095163"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n val N = readLine()!!.toLong()\n\n\n val sqrtN = Math.sqrt(N.toDouble()).toLong()\n\n // log_10(x)\n fun digits(x: Long) : Int {\n var num = x\n var count = 0\n while (num > 0) {\n num /= 10\n count++\n }\n return count\n }\n\n fun F(A: Long, B: Long) : Int {\n return Math.max(digits(A), digits(B))\n }\n\n var answer = Int.MAX_VALUE\n // O(N^0.5 * log_10 N)\n (1..sqrtN).forEach { A ->\n if (N % A == 0L) {\n val B = N / A\n answer = Math.min(answer, F(A, B))\n }\n }\n println(answer)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 630, "cpu_time_ms": 230, "memory_kb": 33660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s757248344", "group_id": "codeNet:p03777", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ')\n val ans = when (a) {\n \"H\" -> b\n else -> if (b == \"H\") \"D\" else \"H\"\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1551849312, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03777.html", "problem_id": "p03777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03777/input.txt", "sample_output_relpath": "derived/input_output/data/p03777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03777/Kotlin/s757248344.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s757248344", "user_id": "u051841332"}, "prompt_components": {"gold_output": "H\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ')\n val ans = when (a) {\n \"H\" -> b\n else -> if (b == \"H\") \"D\" else \"H\"\n }\n println(ans)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "sample_input": "H H\n"}, "reference_outputs": ["H\n"], "source_document_id": "p03777", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 252, "memory_kb": 37980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s533316900", "group_id": "codeNet:p03780", "input_text": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n\n val fdp = Array(n+1){BooleanArray(k)}\n val bdp = Array(n+1){BooleanArray(k)}\n\n\n for(i in 1..n) {\n fdp[i-1][0] = true\n val v = arr[i - 1]\n for(j in 1 until k) {\n if(j - v < 0) continue\n fdp[i][j] = fdp[i-1][j] or fdp[i-1][j-v]\n }\n }\n\n for(i in 1..n) {\n bdp[i-1][0] = true\n val v = arr[n - i]\n for(j in 1 until k) {\n if(j - v < 0) continue\n bdp[i][j] = bdp[i-1][j] or bdp[i-1][j-v]\n }\n }\n\n var ans = 0\n for(i in 0 until n) {\n if(arr[i] >= k)\n continue\n\n val f = fdp[i]\n val b = bdp[n - 1 - i]\n\n var has = false\n\n for(j in 0 until k) {\n if(!f[j]) continue\n if(j >= k - arr[i] && j < k - 1) {\n has = true\n break\n }\n }\n\n if(has) {\n continue\n }\n\n for(j in 0 until k) {\n if(!b[j]) continue\n if(j >= k - arr[i] && j < k - 1) {\n has = true\n break\n }\n }\n\n if(has) {\n continue\n }\n\n // f[j] 에서 k - arr[i] 보다 작은 애들.\n // b[j] 에서 k - arr[i] 보다 작은 애들.\n val l1 = ArrayList()\n\n for(j in 1 until k) {\n if(!f[j]) continue\n l1.add(j)\n }\n\n val r1 = TreeSet()\n for(j in 1 until k) {\n if(!b[j]) continue\n r1.add(j)\n }\n\n val req = k - arr[i] - 1\n for(d in l1) {\n val v = r1.higher(req - d)?:continue\n if(v + d >= k) {\n break\n }\n has = true\n break\n }\n\n if(!has) {\n ++ans\n }\n }\n print(ans)\n\n\n}", "language": "Kotlin", "metadata": {"date": 1596038678, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03780/input.txt", "sample_output_relpath": "derived/input_output/data/p03780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03780/Kotlin/s533316900.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s533316900", "user_id": "u682597394"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.collections.ArrayList\n\nfun main() {\n val (n,k) = readLine()!!.split(\" \").map { it.toInt() }\n val arr = readLine()!!.split(\" \").map { it.toInt() }.sorted()\n\n val fdp = Array(n+1){BooleanArray(k)}\n val bdp = Array(n+1){BooleanArray(k)}\n\n\n for(i in 1..n) {\n fdp[i-1][0] = true\n val v = arr[i - 1]\n for(j in 1 until k) {\n if(j - v < 0) continue\n fdp[i][j] = fdp[i-1][j] or fdp[i-1][j-v]\n }\n }\n\n for(i in 1..n) {\n bdp[i-1][0] = true\n val v = arr[n - i]\n for(j in 1 until k) {\n if(j - v < 0) continue\n bdp[i][j] = bdp[i-1][j] or bdp[i-1][j-v]\n }\n }\n\n var ans = 0\n for(i in 0 until n) {\n if(arr[i] >= k)\n continue\n\n val f = fdp[i]\n val b = bdp[n - 1 - i]\n\n var has = false\n\n for(j in 0 until k) {\n if(!f[j]) continue\n if(j >= k - arr[i] && j < k - 1) {\n has = true\n break\n }\n }\n\n if(has) {\n continue\n }\n\n for(j in 0 until k) {\n if(!b[j]) continue\n if(j >= k - arr[i] && j < k - 1) {\n has = true\n break\n }\n }\n\n if(has) {\n continue\n }\n\n // f[j] 에서 k - arr[i] 보다 작은 애들.\n // b[j] 에서 k - arr[i] 보다 작은 애들.\n val l1 = ArrayList()\n\n for(j in 1 until k) {\n if(!f[j]) continue\n l1.add(j)\n }\n\n val r1 = TreeSet()\n for(j in 1 until k) {\n if(!b[j]) continue\n r1.add(j)\n }\n\n val req = k - arr[i] - 1\n for(d in l1) {\n val v = r1.higher(req - d)?:continue\n if(v + d >= k) {\n break\n }\n has = true\n break\n }\n\n if(!has) {\n ++ans\n }\n }\n print(ans)\n\n\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "sample_input": "3 6\n1 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03780", "source_text": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1995, "cpu_time_ms": 2209, "memory_kb": 128104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s429362524", "group_id": "codeNet:p03780", "input_text": "fun main(args: Array) {\n val (N, K) = listOfInt()\n val A = listOfInt().sorted()\n fun isNeed(mid: Int): Boolean {\n val dp = Array(N + 1) { BooleanArray(K + 1) }\n dp[0][0] = true\n for (n in 0 until N) {\n for (k in 0 until K) {\n dp[n + 1][k] = dp[n + 1][k] or dp[n][k]\n if (n != mid && k <= K - A[n]) {\n dp[n + 1][k + A[n]] = dp[n + 1][k + A[n]] or dp[n][k]\n }\n }\n }\n for (k in Math.max(K - A[mid], 0) until K) {\n if (dp[N][k]) return true\n }\n return false\n }\n var not = -1\n var ans = N\n while (Math.abs(ans - not) > 1) {\n val mid = (ans + not) / 2\n if (isNeed(mid)) ans = mid\n else not = mid\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\n", "language": "Kotlin", "metadata": {"date": 1586099546, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03780/input.txt", "sample_output_relpath": "derived/input_output/data/p03780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03780/Kotlin/s429362524.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s429362524", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = listOfInt()\n val A = listOfInt().sorted()\n fun isNeed(mid: Int): Boolean {\n val dp = Array(N + 1) { BooleanArray(K + 1) }\n dp[0][0] = true\n for (n in 0 until N) {\n for (k in 0 until K) {\n dp[n + 1][k] = dp[n + 1][k] or dp[n][k]\n if (n != mid && k <= K - A[n]) {\n dp[n + 1][k + A[n]] = dp[n + 1][k + A[n]] or dp[n][k]\n }\n }\n }\n for (k in Math.max(K - A[mid], 0) until K) {\n if (dp[N][k]) return true\n }\n return false\n }\n var not = -1\n var ans = N\n while (Math.abs(ans - not) > 1) {\n val mid = (ans + not) / 2\n if (isNeed(mid)) ans = mid\n else not = mid\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "sample_input": "3 6\n1 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03780", "source_text": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1079, "cpu_time_ms": 2111, "memory_kb": 170560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s535111537", "group_id": "codeNet:p03780", "input_text": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }.sorted()\n\n // 前 [0,i)で作れるか\n val front = Array(n) { BitSet(k + 1) }\n front[0][0] = true\n for (i in 0 until n - 1) {\n front[i + 1].or(front[i])\n for (j in 0..k) {\n if (front[i][j]) {\n front[i + 1][Math.min(j + a[i], k)] = true\n }\n }\n }\n\n // 後ろ (i, n)で作れるか\n val back = Array(n) { BitSet(k + 1) }\n back[n - 1][0] = true\n for (i in n - 1 downTo 1) {\n back[i - 1].or(back[i])\n for (j in 0..k) {\n if (back[i][j]) {\n back[i - 1][Math.min(j + a[i], k)] = true\n }\n }\n }\n\n // カードiが不必要 iより小さいカードも不必要\n\n // 必要か?\n var ok = n\n var ng = -1\n\n while (ok - ng > 1) {\n val med = (ok + ng) / 2\n var flag = false\n for (i in 0..k) {\n if (!front[med][i]) continue\n if (k - i - a[med] < 0 ) continue\n for (j in k - i - a[med] until k - i) {\n if (!back[med][j]) continue\n if (i + j < k && k <= i + j + a[med]) {\n flag = true\n }\n }\n }\n if (flag) {\n ok = med\n } else {\n ng = med\n }\n }\n\n println(ok)\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "language": "Kotlin", "metadata": {"date": 1582442216, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03780/input.txt", "sample_output_relpath": "derived/input_output/data/p03780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03780/Kotlin/s535111537.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s535111537", "user_id": "u194412908"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\nimport kotlin.*\n\nimport java.io.InputStream\nimport java.lang.NumberFormatException\nimport java.lang.StringBuilder\n\n\nfun main(args: Array) {\n Program().solve()\n}\n\nclass Program {\n fun solve() {\n val sc = FastScanner()\n val n = sc.nextInt()\n val k = sc.nextInt()\n val a = (1..n).map { sc.nextInt() }.sorted()\n\n // 前 [0,i)で作れるか\n val front = Array(n) { BitSet(k + 1) }\n front[0][0] = true\n for (i in 0 until n - 1) {\n front[i + 1].or(front[i])\n for (j in 0..k) {\n if (front[i][j]) {\n front[i + 1][Math.min(j + a[i], k)] = true\n }\n }\n }\n\n // 後ろ (i, n)で作れるか\n val back = Array(n) { BitSet(k + 1) }\n back[n - 1][0] = true\n for (i in n - 1 downTo 1) {\n back[i - 1].or(back[i])\n for (j in 0..k) {\n if (back[i][j]) {\n back[i - 1][Math.min(j + a[i], k)] = true\n }\n }\n }\n\n // カードiが不必要 iより小さいカードも不必要\n\n // 必要か?\n var ok = n\n var ng = -1\n\n while (ok - ng > 1) {\n val med = (ok + ng) / 2\n var flag = false\n for (i in 0..k) {\n if (!front[med][i]) continue\n if (k - i - a[med] < 0 ) continue\n for (j in k - i - a[med] until k - i) {\n if (!back[med][j]) continue\n if (i + j < k && k <= i + j + a[med]) {\n flag = true\n }\n }\n }\n if (flag) {\n ok = med\n } else {\n ng = med\n }\n }\n\n println(ok)\n }\n}\n\n\nclass FastScanner {\n companion object {\n val input: InputStream = System.`in`\n val buffer = ByteArray(1024) { 0 }\n fun isPrintableChar(c: Int): Boolean = c in 33..126\n }\n\n var ptr = 0\n var buflen = 0\n private fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = input.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n\n private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1\n\n private fun skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n }\n\n fun hasNext(): Boolean {\n skipUnprintable()\n return hasNextByte()\n }\n\n 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 fun nextInt(): Int {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var b = readByte()\n // '-' = 45\n val minus = b == 45\n if (minus) {\n b = readByte()\n }\n\n // '0' = 48 '9' = 57\n if (b !in 48..57) {\n throw NumberFormatException()\n }\n\n while (true) {\n if (b in 48..57) {\n n *= 10\n n += b - 48\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 fun nextDouble(): Double = next().toDouble()\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "sample_input": "3 6\n1 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03780", "source_text": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4336, "cpu_time_ms": 913, "memory_kb": 44332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s745607474", "group_id": "codeNet:p03780", "input_text": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map {it.toInt()}\n val a = readLine()!!.split(\" \").map{it.toLong()}.sorted()\n\n var l = 0\n var u = a.size\n\n while (u - l > 1) {\n val c = (l + u) / 2\n\n fun judge(c: Int): Boolean {\n if (a[c] >= K) return true\n\n val dp = BooleanArray(K) { false }\n dp[0] = true\n\n for (i in a.indices) {\n if (i == c) continue\n for (k in K - 1 downTo a[i].toInt()) {\n dp[k] = dp[k] || dp[k - a[i].toInt()]\n }\n }\n\n for (i in Math.max(0, K - a[c].toInt()) until K) {\n if (dp[i]) return true\n }\n\n return false\n }\n\n if (judge(c)) {\n u = c\n } else {\n l = c\n }\n }\n\n println(u)\n}\n", "language": "Kotlin", "metadata": {"date": 1579101780, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03780.html", "problem_id": "p03780", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03780/input.txt", "sample_output_relpath": "derived/input_output/data/p03780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03780/Kotlin/s745607474.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s745607474", "user_id": "u183530284"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, K) = readLine()!!.split(\" \").map {it.toInt()}\n val a = readLine()!!.split(\" \").map{it.toLong()}.sorted()\n\n var l = 0\n var u = a.size\n\n while (u - l > 1) {\n val c = (l + u) / 2\n\n fun judge(c: Int): Boolean {\n if (a[c] >= K) return true\n\n val dp = BooleanArray(K) { false }\n dp[0] = true\n\n for (i in a.indices) {\n if (i == c) continue\n for (k in K - 1 downTo a[i].toInt()) {\n dp[k] = dp[k] || dp[k - a[i].toInt()]\n }\n }\n\n for (i in Math.max(0, K - a[c].toInt()) until K) {\n if (dp[i]) return true\n }\n\n return false\n }\n\n if (judge(c)) {\n u = c\n } else {\n l = c\n }\n }\n\n println(u)\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "sample_input": "3 6\n1 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03780", "source_text": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 872, "cpu_time_ms": 977, "memory_kb": 42536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s601997016", "group_id": "codeNet:p03785", "input_text": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun bsCondOpCl(A: LongArray, L: Int, R: Int, C: Int, K: Int): Int {\n val N = A.size\n fun isCondition(A: LongArray, m: Int): Boolean {\n var cnt = 1\n var i = 0\n var sum = 0\n var nt = A[0] + K\n while (i < N) {\n if (sum >= C || A[i] > nt) {\n cnt++\n sum = 0\n nt = A[i] + K\n }\n\n if (cnt > m) return false\n\n if (sum < C && A[i] <= nt) {\n sum++\n i++\n }\n }\n return true\n }\n var l = L; var r = R\n while (l+1 < r) {\n val m = (l + r) / 2\n if (isCondition(A, m)) {\n r = m\n } else {\n l = m\n }\n }\n return r\n}\n\n\nfun solve() {\n val (N, C, K) = rd.readIntArray()\n val T = rd.readLongColumn(N).sorted()\n\n val ans = bsCondOpCl(T.toLongArray(), 0, N, C, K)\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"011\", \"a\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntColumn: (Int) -> IntArray = { N -> (0 until N).map { readInt() }.toIntArray() }\n val readLongColumn: (Int) -> LongArray = { N -> (0 until N).map { readLong() }.toLongArray() }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "language": "Kotlin", "metadata": {"date": 1598132590, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03785.html", "problem_id": "p03785", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03785/input.txt", "sample_output_relpath": "derived/input_output/data/p03785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03785/Kotlin/s601997016.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601997016", "user_id": "u404244809"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*\nimport java.util.*\nimport java.lang.*\nimport java.lang.Math.*\n\n\nfun bsCondOpCl(A: LongArray, L: Int, R: Int, C: Int, K: Int): Int {\n val N = A.size\n fun isCondition(A: LongArray, m: Int): Boolean {\n var cnt = 1\n var i = 0\n var sum = 0\n var nt = A[0] + K\n while (i < N) {\n if (sum >= C || A[i] > nt) {\n cnt++\n sum = 0\n nt = A[i] + K\n }\n\n if (cnt > m) return false\n\n if (sum < C && A[i] <= nt) {\n sum++\n i++\n }\n }\n return true\n }\n var l = L; var r = R\n while (l+1 < r) {\n val m = (l + r) / 2\n if (isCondition(A, m)) {\n r = m\n } else {\n l = m\n }\n }\n return r\n}\n\n\nfun solve() {\n val (N, C, K) = rd.readIntArray()\n val T = rd.readLongColumn(N).sorted()\n\n val ans = bsCondOpCl(T.toLongArray(), 0, N, C, K)\n println(ans)\n}\n\n\n//val rd = debug.Reader(\"agc\", \"011\", \"a\", \"sample-2\")\nval rd = Reader()\n\n\nfun main(args: Array) {\n try {\n var exception: Throwable? = null\n val sth = Thread(null, SolveThread(), \"solveThread\", 128 * 1024 * 1024)\n sth.setUncaughtExceptionHandler { _, e -> exception = e }\n sth.start(); sth.join()\n if (exception != null) throw exception!! }\n catch (e: Exception) { throw e }\n finally { rd.close() }\n}\nconst val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2\ndata class IntPair(val first: Int, val second: Int)\nval errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }\nfun rAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"EAssert Error: $msg\"); throw Error(msg) }\n}\nfun tAssert(exp: Boolean, lazyMsg: () -> String = {\"\"}) {\n if (!exp) { val msg = lazyMsg(); errPrintln(\"TAssert Error: $msg\"); Thread.sleep(3000) }\n}\nclass SolveThread : Runnable {\n override fun run() { solve() }\n}\nclass Reader {\n private val br = BufferedReader(InputStreamReader(System.`in`))\n val readString: () -> String = { br.readLine() }\n val readInt: () -> Int = { br.readLine().toInt() }\n val readLong: () -> Long = { br.readLine().toLong() }\n val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }\n val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }\n val readListInt: () -> List = { br.readLine().split(' ').map { it.toInt() } }\n val readListLong: () -> List = { br.readLine().split(' ').map { it.toLong() } }\n val readIntColumn: (Int) -> IntArray = { N -> (0 until N).map { readInt() }.toIntArray() }\n val readLongColumn: (Int) -> LongArray = { N -> (0 until N).map { readLong() }.toLongArray() }\n val close: () -> Unit = { br.close() }\n protected fun finalize() { close() }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "sample_input": "5 3 5\n1\n2\n3\n6\n12\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03785", "source_text": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2950, "cpu_time_ms": 426, "memory_kb": 59452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s271951209", "group_id": "codeNet:p03785", "input_text": "fun main(args: Array){\n val (N, C, K) = readLine()!!.split(\" \").map { it.toLong() }\n val T = LongArray(N.toInt()){ readLine()!!.toLong() }.sorted().toLongArray()\n\n var busCount = 0L\n var first = -1L\n var count = 0L\n for(i in T.indices){\n if(first == -1L){\n count++\n first = T[i]\n }else{\n if(first + K >= T[i] && count < C){\n count++\n }else{\n busCount++\n first = T[i]\n count = 1L\n }\n }\n }\n println(busCount + 1)\n}", "language": "Kotlin", "metadata": {"date": 1591640242, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03785.html", "problem_id": "p03785", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03785/input.txt", "sample_output_relpath": "derived/input_output/data/p03785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03785/Kotlin/s271951209.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271951209", "user_id": "u531770859"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array){\n val (N, C, K) = readLine()!!.split(\" \").map { it.toLong() }\n val T = LongArray(N.toInt()){ readLine()!!.toLong() }.sorted().toLongArray()\n\n var busCount = 0L\n var first = -1L\n var count = 0L\n for(i in T.indices){\n if(first == -1L){\n count++\n first = T[i]\n }else{\n if(first + K >= T[i] && count < C){\n count++\n }else{\n busCount++\n first = T[i]\n count = 1L\n }\n }\n }\n println(busCount + 1)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "sample_input": "5 3 5\n1\n2\n3\n6\n12\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03785", "source_text": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 580, "cpu_time_ms": 693, "memory_kb": 47488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s861515838", "group_id": "codeNet:p03787", "input_text": "import java.util.*\n\ndata class Component(val size: Int, val bipartite: Boolean)\n\n// Reads multiple ints in a line, separate by a space.\n// It works even if the actual number of ints is smaller than n.\n// WARNING: This function does not work for -2^31.\n// NOTE: This function does not handle error cases.\nfun fastReadInts(n: Int): IntArray {\n val xs = IntArray(n)\n val s = readLine()!!\n var currentValue = 0\n var isNegative = false\n var currentIndex = 0\n for (c in s) {\n if (c == ' ') {\n xs[currentIndex] = currentValue * if (isNegative) -1 else 1\n currentValue = 0\n isNegative = false\n currentIndex++\n } else if (c == '-') {\n isNegative = true\n } else {\n currentValue *= 10\n currentValue += c - '0'\n }\n }\n xs[currentIndex] = currentValue * if (isNegative) -1 else 1\n return xs\n}\n\ndata class BFSState(val v: Int, val c: Int)\n\nfun main(args: Array) {\n val (n, m) = fastReadInts(2)\n val graph = Array(n, { mutableListOf() })\n repeat(m) {\n val (v1Raw, v2Raw) = fastReadInts(2)\n val v1 = v1Raw - 1\n val v2 = v2Raw - 1\n graph[v1].add(v2)\n graph[v2].add(v1)\n }\n\n val colors = IntArray(n, { -1 })\n val components = mutableListOf()\n var numIsolated = 0\n for (s in 0 until n) {\n if (colors[s] >= 0) continue\n if (graph[s].isEmpty()) {\n colors[s] = 0\n numIsolated += 1\n continue\n }\n\n var componentSize = 0\n var isBipartite = true\n\n // BFS\n val queue = ArrayDeque()\n componentSize += 1\n colors[s] = 0\n queue.offerLast(BFSState(s, 0))\n while (queue.isNotEmpty()) {\n val state = queue.pollFirst()\n val v = state.v\n val c = state.c\n val nextC = (c + 1) % 2\n\n // Bipartite check\n for (u in graph[v]) {\n if (colors[u] >= 0 && colors[u] == c) {\n isBipartite = false\n }\n }\n\n for (u in graph[v]) {\n if (colors[u] >= 0) continue\n componentSize += 1\n colors[u] = nextC\n queue.offerLast(BFSState(u, nextC))\n }\n }\n\n components.add(Component(componentSize, isBipartite))\n }\n\n// println(\"components: \" + components)\n// println(\"numIsolated: \" + numIsolated)\n\n var ans = 0L\n for (c1 in components) {\n for (c2 in components) {\n if (c1.bipartite && c2.bipartite) {\n ans += 2L\n } else {\n ans += 1L\n }\n }\n }\n\n ans += 2L * n.toLong() * numIsolated.toLong() - numIsolated.toLong() * numIsolated.toLong()\n\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1525549423, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03787.html", "problem_id": "p03787", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03787/input.txt", "sample_output_relpath": "derived/input_output/data/p03787/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03787/Kotlin/s861515838.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s861515838", "user_id": "u771276542"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*\n\ndata class Component(val size: Int, val bipartite: Boolean)\n\n// Reads multiple ints in a line, separate by a space.\n// It works even if the actual number of ints is smaller than n.\n// WARNING: This function does not work for -2^31.\n// NOTE: This function does not handle error cases.\nfun fastReadInts(n: Int): IntArray {\n val xs = IntArray(n)\n val s = readLine()!!\n var currentValue = 0\n var isNegative = false\n var currentIndex = 0\n for (c in s) {\n if (c == ' ') {\n xs[currentIndex] = currentValue * if (isNegative) -1 else 1\n currentValue = 0\n isNegative = false\n currentIndex++\n } else if (c == '-') {\n isNegative = true\n } else {\n currentValue *= 10\n currentValue += c - '0'\n }\n }\n xs[currentIndex] = currentValue * if (isNegative) -1 else 1\n return xs\n}\n\ndata class BFSState(val v: Int, val c: Int)\n\nfun main(args: Array) {\n val (n, m) = fastReadInts(2)\n val graph = Array(n, { mutableListOf() })\n repeat(m) {\n val (v1Raw, v2Raw) = fastReadInts(2)\n val v1 = v1Raw - 1\n val v2 = v2Raw - 1\n graph[v1].add(v2)\n graph[v2].add(v1)\n }\n\n val colors = IntArray(n, { -1 })\n val components = mutableListOf()\n var numIsolated = 0\n for (s in 0 until n) {\n if (colors[s] >= 0) continue\n if (graph[s].isEmpty()) {\n colors[s] = 0\n numIsolated += 1\n continue\n }\n\n var componentSize = 0\n var isBipartite = true\n\n // BFS\n val queue = ArrayDeque()\n componentSize += 1\n colors[s] = 0\n queue.offerLast(BFSState(s, 0))\n while (queue.isNotEmpty()) {\n val state = queue.pollFirst()\n val v = state.v\n val c = state.c\n val nextC = (c + 1) % 2\n\n // Bipartite check\n for (u in graph[v]) {\n if (colors[u] >= 0 && colors[u] == c) {\n isBipartite = false\n }\n }\n\n for (u in graph[v]) {\n if (colors[u] >= 0) continue\n componentSize += 1\n colors[u] = nextC\n queue.offerLast(BFSState(u, nextC))\n }\n }\n\n components.add(Component(componentSize, isBipartite))\n }\n\n// println(\"components: \" + components)\n// println(\"numIsolated: \" + numIsolated)\n\n var ans = 0L\n for (c1 in components) {\n for (c2 in components) {\n if (c1.bipartite && c2.bipartite) {\n ans += 2L\n } else {\n ans += 1L\n }\n }\n }\n\n ans += 2L * n.toLong() * numIsolated.toLong() - numIsolated.toLong() * numIsolated.toLong()\n\n println(ans)\n}\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nTakahashi has received an undirected graph with N vertices, numbered 1, 2, ..., N.\nThe edges in this graph are represented by (u_i, v_i).\nThere are no self-loops and multiple edges in this graph.\n\nBased on this graph, Takahashi is now constructing a new graph with N^2 vertices, where each vertex is labeled with a pair of integers (a, b) (1 \\leq a \\leq N, 1 \\leq b \\leq N).\nThe edges in this new graph are generated by the following rule:\n\nSpan an edge between vertices (a, b) and (a', b') if and only if both of the following two edges exist in the original graph: an edge between vertices a and a', and an edge between vertices b and b'.\n\nHow many connected components are there in this new graph?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n0 \\leq M \\leq 200,000\n\n1 \\leq u_i < v_i \\leq N\n\nThere exists no pair of distinct integers i and j such that u_i = u_j and v_i = v_j.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nu_1 v_1\nu_2 v_2\n:\nu_M v_M\n\nOutput\n\nPrint the number of the connected components in the graph constructed by Takahashi.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n7\n\nThe graph constructed by Takahashi is as follows.\n\nSample Input 2\n\n7 5\n1 2\n3 4\n3 5\n4 5\n2 6\n\nSample Output 2\n\n18", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03787", "source_text": "Score : 800 points\n\nProblem Statement\n\nTakahashi has received an undirected graph with N vertices, numbered 1, 2, ..., N.\nThe edges in this graph are represented by (u_i, v_i).\nThere are no self-loops and multiple edges in this graph.\n\nBased on this graph, Takahashi is now constructing a new graph with N^2 vertices, where each vertex is labeled with a pair of integers (a, b) (1 \\leq a \\leq N, 1 \\leq b \\leq N).\nThe edges in this new graph are generated by the following rule:\n\nSpan an edge between vertices (a, b) and (a', b') if and only if both of the following two edges exist in the original graph: an edge between vertices a and a', and an edge between vertices b and b'.\n\nHow many connected components are there in this new graph?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n0 \\leq M \\leq 200,000\n\n1 \\leq u_i < v_i \\leq N\n\nThere exists no pair of distinct integers i and j such that u_i = u_j and v_i = v_j.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nu_1 v_1\nu_2 v_2\n:\nu_M v_M\n\nOutput\n\nPrint the number of the connected components in the graph constructed by Takahashi.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n7\n\nThe graph constructed by Takahashi is as follows.\n\nSample Input 2\n\n7 5\n1 2\n3 4\n3 5\n4 5\n2 6\n\nSample Output 2\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2494, "cpu_time_ms": 2111, "memory_kb": 63852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s582142954", "group_id": "codeNet:p03800", "input_text": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val n = nextLong()\n val s = next()\n val t = boolAry(n)\n for (i in 0 until n) {\n if(s[i] == 'o') t[i] = true\n }\n\n // pattern1 sheep\n when (t[0]) {\n true -> { // 1がo\n // 1-1 side sheep\n var tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 1L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf\n tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 2L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n false -> { // 1がx\n // 1-3 side sheep-wolf\n var tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 1L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf-sheep\n tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 2L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n }\n\n // pattern2 wolf\n when (t[0]) {\n true -> { // 1がo\n // 1-1 side sheep-wolf\n var tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 1L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf-sheep\n tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 2L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n false -> { // 1がx\n // 1-3 side sheep\n var tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 1L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf\n tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 2L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n }\n\n println(-1)\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "language": "Kotlin", "metadata": {"date": 1588680554, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03800.html", "problem_id": "p03800", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03800/input.txt", "sample_output_relpath": "derived/input_output/data/p03800/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03800/Kotlin/s582142954.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s582142954", "user_id": "u581625805"}, "prompt_components": {"gold_output": "SSSWWS\n", "input_to_evaluate": "import java.io.*\nimport java.lang.*\nimport java.util.*\n\n// Constant\nval sc = FastScanner()\nval pw = PrintWriter(System.out)\nconst val MOD = 1000000007L\nconst val INF = 9223372036854775807L\n\n// Main\nfun main(args: Array) {\n solve()\n pw.flush()\n}\n\nfun solve() {\n val n = nextLong()\n val s = next()\n val t = boolAry(n)\n for (i in 0 until n) {\n if(s[i] == 'o') t[i] = true\n }\n\n // pattern1 sheep\n when (t[0]) {\n true -> { // 1がo\n // 1-1 side sheep\n var tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 1L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf\n tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 2L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n false -> { // 1がx\n // 1-3 side sheep-wolf\n var tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 1L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf-sheep\n tmp1 = longAry(n)\n tmp1[0] = 1L\n tmp1[1] = 2L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n }\n\n // pattern2 wolf\n when (t[0]) {\n true -> { // 1がo\n // 1-1 side sheep-wolf\n var tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 1L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf-sheep\n tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 2L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n false -> { // 1がx\n // 1-3 side sheep\n var tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 1L\n //tmp1[n - 1] = 1L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res1 = tmp1[n - 1] == 1L && if(t[n - 1]) tmp1[0] == tmp1[n - 2] else tmp1[0] != tmp1[n - 2]\n if(res1) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n // 1-2 side wolf\n tmp1 = longAry(n)\n tmp1[0] = 2L\n tmp1[1] = 2L\n //tmp1[n - 1] = 2L\n for (i in 1 until n - 1) {\n when (tmp1[i]) {\n 1L -> {\n if(t[i]) tmp1[i + 1] = tmp1[i - 1]\n else tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n }\n 2L -> {\n if(t[i]) tmp1[i + 1] = if(tmp1[i - 1] == 1L) 2L else 1L\n else tmp1[i + 1] = tmp1[i - 1]\n }\n }\n }\n val res2 = tmp1[n - 1] == 2L && if(t[n - 1]) tmp1[0] != tmp1[n - 2] else tmp1[0] == tmp1[n - 2]\n if(res2) {\n val ans = tmp1.map { if(it == 1L) 'S' else 'W' }\n println(ans.joinToString(\"\"))\n return\n }\n }\n }\n\n println(-1)\n\n}\n\n\n\n// Rule\noperator fun String.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.get(index: Long): Char {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun CharArray.set(index: Long, value: Char) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun LongArray.get(index: Long): Long {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun LongArray.set(index: Long, value: Long) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun DoubleArray.get(index: Long): Double {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun DoubleArray.set(index: Long, value: Double) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun Array.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun Array.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\noperator fun MutableList.get(index: Long): T {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n return this[index.toInt()]\n}\noperator fun MutableList.set(index: Long, value: T) {\n if (index !in 0L..Int.MAX_VALUE) throw IllegalArgumentException()\n this[index.toInt()] = value\n}\n\nval LongArray.siz: Long\n get() = size.toLong()\nval Array.siz: Long\n get() = size.toLong()\nval MutableList.siz: Long\n get() = size.toLong()\nval MutableSet.siz: Long\n get() = size.toLong()\nval String.len: Long\n get() = length.toLong()\n\n// Output\nfun println(v: String) {\n pw.println(v)\n}\nfun print(v: String) {\n pw.print(v)\n}\n\n// Input\nfun next() = sc.next()\nfun nextLong() = sc.nextLong()\nfun nextDouble() = next().toDouble()\nfun nextAry(n: Long): Array {\n val ary = ary(n)\n for (i in 0 until n) ary[i] = next()\n return ary\n}\nfun nextLongAry(n: Long): LongArray {\n val ary = longAry(n)\n for (i in 0 until n) ary[i] = nextLong()\n return ary\n}\nfun nextDoubleAry(n: Long): DoubleArray {\n val ary = doubleAry(n)\n for (i in 0 until n) ary[i] = nextDouble()\n return ary\n}\n\n// Statement\nfun ary(n: Long, init: String = \"\") = Array(n.toInt()) { init }\nfun longAry(n: Long, init: Long = 0L) = LongArray(n.toInt()) { init }\nfun doubleAry(n: Long, init: Double = 0.0) = DoubleArray(n.toInt()) { init }\nfun boolAry(n: Long, init: Boolean = false) = Array(n.toInt()) { init }\nfun ary2(n: Long, m: Long, init: String = \"\") = Array(n.toInt()) { ary(m, init) }\nfun longAry2(n: Long, m: Long, init: Long = 0) = Array(n.toInt()) { longAry(m, init) }\nfun doubleAry2(n: Long, m: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry(m, init) }\nfun boolAry2(n: Long, m: Long, init: Boolean = false) = Array(n.toInt()) { boolAry(m, init) }\nfun ary3(n: Long, m: Long, k: Long, init: String = \"\") = Array(n.toInt()) { ary2(m, k, init) }\nfun longAry3(n: Long, m: Long, k: Long, init: Long = 0L) = Array(n.toInt()) { longAry2(m, k, init) }\nfun doubleAry3(n: Long, m: Long, k: Long, init: Double = 0.0) = Array(n.toInt()) { doubleAry2(m, k, init) }\nfun boolAry3(n: Long, m: Long, k: Long, init: Boolean = false) = Array(n.toInt()) { boolAry2(m, k, init) }\nfun list() = mutableListOf()\nfun longList() = mutableListOf()\nfun doubleList() = mutableListOf()\nfun strSet() = mutableSetOf()\nfun longSet() = mutableSetOf()\nfun doubleSet() = mutableSetOf()\nfun map() = mutableMapOf()\n\n// Monoid\nval addFunc = {a: Long, b: Long -> a + b}\nval mulFunc = {a: Long, b: Long -> a * b}\nval maxFunc = {a: Long, b: Long -> max(a, b)}\nval minFunc = {a: Long, b: Long -> min(a, b)}\nval gcdFunc = {a: Long, b: Long -> gcd(a, b)}\nval lcmFunc = {a: Long, b: Long -> lcm(a, b)}\nval xorFunc = {a: Long, b: Long -> a xor b}\nfun calc(a: Long, b: Long, op: (Long, Long) -> Long) = op(a, b)\n\n// Extension\nfun LongArray.lowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun DoubleArray.lowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.longLowerBound(n: Long): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun MutableList.doubleLowerBound(n: Double): Long {\n var ok = this.size.toLong()\n var ng = -1L\n while (abs(ok - ng) > 1) {\n val mid = (ok + ng) / 2\n if (this[mid] >= n) ok = mid\n else ng = mid\n }\n return ok\n}\nfun LongArray.cumsum(op: (Long, Long) -> Long): LongArray {\n val s = longAry(this.size + 1L)\n s[1] = this[0]\n for (i in 1 until this.size) s[i + 1] = calc(s[i], this[i], op)\n return s\n}\nfun MutableMap.counting(n: Long) {\n repeat(n.toInt()) {\n val a = next()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\nfun MutableMap.longCounting(n: Long) {\n repeat(n.toInt()) {\n val a = nextLong()\n if (this.containsKey(a)) this[a] = this[a]!! + 1\n else this[a] = 1\n }\n}\n\n// Mathematics\nfun abs(n: Long): Long = Math.abs(n)\nfun abs(n: Double): Double = Math.abs(n)\nfun max(vararg values: Long) = if (values.isEmpty()) -INF else values.max()!!\nfun min(vararg values: Long) = if (values.isEmpty()) INF else values.min()!!\ntailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else if (a % b == 0L) b else gcd(b, (a % b))\nfun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b\nfun modpow(a: Long, n: Long, p: Long = MOD): Long {\n var res = 1L\n var ar = a\n var nr = n\n while (nr > 0) {\n if ((nr and 1) == 1L) res = res * ar % p\n ar = ar * ar % p\n nr = nr shr 1\n }\n return res\n}\nfun modinv(a: Long, p: Long = MOD): Long = modpow(a, p - 2, p)\nfun ncr(n: Long, r: Long): Long {\n var a = 1L\n var b = 1L\n for (i in 1..r) {\n a = a * (n + 1 - i) % MOD\n b = b * i % MOD\n }\n return modinv(b, MOD) * a % MOD\n}\n\nclass Combination(private val max: Long) {\n private val fac = longAry(max)\n private val finv = longAry(max)\n private val inv = longAry(max)\n private val p = MOD\n fun init() {\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for (i in 2 until max) {\n fac[i] = fac[i - 1] * i % p\n inv[i] = p - inv[p % i] * (p / i) % p;\n finv[i] = finv[i - 1] * inv[i] % p\n }\n }\n\n fun com(n: Long, r: Long): Long = if (n < r || (n < 0 || r < 0)) 0L else fac[n] * (finv[r] * finv[n - r] % p) % p\n}\n\nclass Permutation(private val n: Long, private var searched: Long = 0L, private var nextIndex: Long = 0L) {\n private val size = fact(n)\n private val permList = longAry2(size, n)\n\n private tailrec fun fact(n: Long, ans: Long = 1L): Long {\n return if (n == 0L) ans\n else fact(n - 1, ans * n)\n }\n\n fun init() {\n create(0, longAry(n), boolAry(n))\n }\n\n private fun create(num: Long, list: LongArray, flag: Array) {\n if (num == n) {\n permList[searched] = list.copyOf()\n searched++\n }\n for (i in 0 until n) {\n if (flag[i]) continue\n list[num] = i\n flag[i] = true\n create(num + 1, list, flag)\n flag[i] = false\n }\n }\n\n fun hasNext(): Boolean {\n return if (nextIndex < size) {\n true\n } else {\n nextIndex = 0\n false\n }\n }\n\n fun nextPerm(): LongArray = permList[nextIndex++]\n}\n\n// Graph\ndata class Node(val id: Long, var past: Long = -1, val edges: MutableList = mutableListOf())\ndata class Edge(val from: Long, val to: Long, val cost: Long = 1L)\n\nfun dfs(nodes: Array, now: Long, seen: Array) {\n seen[now] = true\n for (edge in nodes[now].edges) {\n if (seen[edge.to]) continue\n dfs(nodes, edge.to, seen)\n }\n}\n\nfun bfs(nodes: Array, start: Long): LongArray {\n val queue = ArrayDeque()\n queue.add(start)\n val dist = longAry(nodes.size.toLong(), -1L)\n dist[start] = 0L\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n for (edge in nodes[now].edges) {\n if (dist[edge.to] != -1L) continue\n dist[edge.to] = dist[now] + 1\n queue.add(edge.to)\n }\n }\n return dist\n}\n\nfun dijkstra(nodes: Array, start: Long): LongArray {\n val queue = PriorityQueue(16) { e1: Edge, e2: Edge ->\n return@PriorityQueue when {\n e1.cost < e2.cost -> -1\n e2.cost > e1.cost -> 1\n else -> 0\n }\n }\n queue.add(Edge(start, start, 0L))\n val dist = longAry(nodes.size.toLong(), INF / 2)\n dist[start] = 0\n while (queue.isNotEmpty()) {\n val now = queue.poll()\n if (dist[now.to] < now.cost) continue;\n for (edge in nodes[now.to].edges) {\n if (dist[edge.to] <= dist[edge.from] + edge.cost) continue\n dist[edge.to] = dist[edge.from] + edge.cost\n queue.add(Edge(edge.from, edge.to, dist[edge.to]))\n nodes[edge.to].past = edge.from\n }\n }\n return dist\n}\n\n// Data Structure\nclass UnionFind(size: Long) {\n private val par = LongArray(size.toInt()) { it.toLong() }\n private val size = longAry(size, 1L)\n fun root(x: Long): Long {\n return if (par[x] == x) {\n x\n } else {\n par[x] = root(par[x])\n par[x]\n }\n }\n\n fun same(x: Long, y: Long): Boolean = root(x) == root(y)\n fun unite(x: Long, y: Long) {\n var a = root(x)\n var b = root(y)\n if (a == b) return\n if (size[a] < size[b]) {\n var tmp = a\n a = b\n b = tmp\n }\n size[a] += size[b]\n par[b] = a\n }\n\n fun size(x: Long): Long = size[root(x)]\n}\n\nclass SegmentTree(\n private val a: LongArray,\n private val op: (Long, Long) -> Long,\n private val def: Long = 0,\n private val size: Int = a.size,\n private val n: Int = Integer.highestOneBit(size) shl 1\n) {\n private val nodes = longAry(2L * n - 1, def)\n\n fun init() {\n for (i in 0 until size) nodes[i + n - 1] = a[i]\n for (i in n - 2 downTo 0) nodes[i] = calc(nodes[2 * i + 1], nodes[2 * i + 2], op)\n }\n\n fun update(x: Long, value: Long) {\n var index = x + n - 1\n nodes[index] = value\n while (index > 0) {\n index = (index - 1) / 2\n nodes[index] = calc(nodes[2 * index + 1], nodes[2 * index + 2], op)\n }\n }\n\n fun get(a: Long, b: Long) = getSub(a, b, 0L, 0L, n.toLong())\n private fun getSub(a: Long, b: Long, k: Long, l: Long, r: Long): Long {\n return when {\n r <= a || b <= l -> def\n a <= l && r <= b -> nodes[k]\n else -> {\n val vl = getSub(a, b, k * 2 + 1, l, (l + r) / 2)\n val vr = getSub(a, b, k * 2 + 2, (l + r) / 2, r)\n calc(vl, vr, op)\n }\n }\n }\n\n fun joinToString(separator: String) = nodes.drop(n - 1).take(size).joinToString(separator)\n}\n\n// Scanner\nclass FastScanner {\n private val sin: InputStream = System.`in`\n private val buffer: ByteArray = ByteArray(1024) { 0 }\n private var ptr = 0\n private var buflen = 0\n\n private fun hasNextByte(): Boolean {\n return when {\n ptr < buflen -> true\n else -> {\n ptr = 0\n buflen = sin.read(buffer)\n buflen > 0\n }\n }\n }\n\n private fun readByte(): Int {\n return when {\n hasNextByte() -> buffer[ptr++].toInt()\n else -> -1\n }\n }\n\n private fun isPrintableChar(c: Int) = c in 33..126\n\n fun hasNext(): Boolean {\n while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++\n return hasNextByte()\n }\n\n 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 fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b.toChar() == '-') {\n minus = true\n b = readByte()\n }\n if (b.toChar() !in '0'..'9') throw NumberFormatException()\n while (true) {\n when {\n b.toChar() in '0'..'9' -> {\n n *= 10\n n += b.toChar() - '0'\n }\n b == -1 || !isPrintableChar(b) -> return if (minus) -n else n\n else -> throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n// \"The world doesn't need you.\"\n//\n// fun nextInt(): Int {\n// val nl = nextLong()\n// if (nl !in Int.MIN_VALUE..Int.MAX_VALUE) throw NumberFormatException()\n// return nl.toInt()\n// }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.\n\nThere are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.\n\nSnuke cannot tell the difference between these two species, and asked each animal the following question: \"Are your neighbors of the same species?\" The animal numbered i answered s_i. Here, if s_i is o, the animal said that the two neighboring animals are of the same species, and if s_i is x, the animal said that the two neighboring animals are of different species.\n\nMore formally, a sheep answered o if the two neighboring animals are both sheep or both wolves, and answered x otherwise.\nSimilarly, a wolf answered x if the two neighboring animals are both sheep or both wolves, and answered o otherwise.\n\nSnuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print -1.\n\nConstraints\n\n3 ≤ N ≤ 10^{5}\n\ns is a string of length N consisting of o and x.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there does not exist an valid assignment that is consistent with s, print -1.\nOtherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.\n\nt is a string of length N consisting of S and W.\n\nIf t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.\n\nSample Input 1\n\n6\nooxoox\n\nSample Output 1\n\nSSSWWS\n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.\n\nSample Input 2\n\n3\noox\n\nSample Output 2\n\n-1\n\nPrint -1 if there is no valid assignment of species.\n\nSample Input 3\n\n10\noxooxoxoox\n\nSample Output 3\n\nSSWWSSSWWS", "sample_input": "6\nooxoox\n"}, "reference_outputs": ["SSSWWS\n"], "source_document_id": "p03800", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.\n\nThere are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.\n\nSnuke cannot tell the difference between these two species, and asked each animal the following question: \"Are your neighbors of the same species?\" The animal numbered i answered s_i. Here, if s_i is o, the animal said that the two neighboring animals are of the same species, and if s_i is x, the animal said that the two neighboring animals are of different species.\n\nMore formally, a sheep answered o if the two neighboring animals are both sheep or both wolves, and answered x otherwise.\nSimilarly, a wolf answered x if the two neighboring animals are both sheep or both wolves, and answered o otherwise.\n\nSnuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print -1.\n\nConstraints\n\n3 ≤ N ≤ 10^{5}\n\ns is a string of length N consisting of o and x.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there does not exist an valid assignment that is consistent with s, print -1.\nOtherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.\n\nt is a string of length N consisting of S and W.\n\nIf t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.\n\nSample Input 1\n\n6\nooxoox\n\nSample Output 1\n\nSSSWWS\n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.\n\nSample Input 2\n\n3\noox\n\nSample Output 2\n\n-1\n\nPrint -1 if there is no valid assignment of species.\n\nSample Input 3\n\n10\noxooxoxoox\n\nSample Output 3\n\nSSWWSSSWWS", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 21714, "cpu_time_ms": 446, "memory_kb": 46376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s192030214", "group_id": "codeNet:p03803", "input_text": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ')\n .map { n -> if (n == \"1\") 14 else n.toInt() }\n val msg = when {\n a < b -> \"Bob\"\n b < a -> \"Alice\"\n else -> \"Draw\"\n }\n println(msg)\n}\n", "language": "Kotlin", "metadata": {"date": 1549684356, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03803.html", "problem_id": "p03803", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03803/input.txt", "sample_output_relpath": "derived/input_output/data/p03803/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03803/Kotlin/s192030214.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192030214", "user_id": "u051841332"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b) = readLine()!!.split(' ')\n .map { n -> if (n == \"1\") 14 else n.toInt() }\n val msg = when {\n a < b -> \"Bob\"\n b < a -> \"Alice\"\n else -> \"Draw\"\n }\n println(msg)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAlice and Bob are playing One Card Poker.\n\nOne Card Poker is a two-player game using playing cards.\n\nEach card in this game shows an integer between 1 and 13, inclusive.\n\nThe strength of a card is determined by the number written on it, as follows:\n\nWeak 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 1 Strong\n\nOne Card Poker is played as follows:\n\nEach player picks one card from the deck. The chosen card becomes the player's hand.\n\nThe players reveal their hands to each other. The player with the stronger card wins the game.\n\nIf their cards are equally strong, the game is drawn.\n\nYou are watching Alice and Bob playing the game, and can see their hands.\n\nThe number written on Alice's card is A, and the number written on Bob's card is B.\n\nWrite a program to determine the outcome of the game.\n\nConstraints\n\n1≦A≦13\n\n1≦B≦13\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint Alice if Alice will win. Print Bob if Bob will win. Print Draw if the game will be drawn.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\nAlice\n\n8 is written on Alice's card, and 6 is written on Bob's card.\nAlice has the stronger card, and thus the output should be Alice.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nDraw\n\nSince their cards have the same number, the game will be drawn.\n\nSample Input 3\n\n13 1\n\nSample Output 3\n\nBob", "sample_input": "8 6\n"}, "reference_outputs": ["Alice\n"], "source_document_id": "p03803", "source_text": "Score : 100 points\n\nProblem Statement\n\nAlice and Bob are playing One Card Poker.\n\nOne Card Poker is a two-player game using playing cards.\n\nEach card in this game shows an integer between 1 and 13, inclusive.\n\nThe strength of a card is determined by the number written on it, as follows:\n\nWeak 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 1 Strong\n\nOne Card Poker is played as follows:\n\nEach player picks one card from the deck. The chosen card becomes the player's hand.\n\nThe players reveal their hands to each other. The player with the stronger card wins the game.\n\nIf their cards are equally strong, the game is drawn.\n\nYou are watching Alice and Bob playing the game, and can see their hands.\n\nThe number written on Alice's card is A, and the number written on Bob's card is B.\n\nWrite a program to determine the outcome of the game.\n\nConstraints\n\n1≦A≦13\n\n1≦B≦13\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint Alice if Alice will win. Print Bob if Bob will win. Print Draw if the game will be drawn.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\nAlice\n\n8 is written on Alice's card, and 6 is written on Bob's card.\nAlice has the stronger card, and thus the output should be Alice.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nDraw\n\nSince their cards have the same number, the game will be drawn.\n\nSample Input 3\n\n13 1\n\nSample Output 3\n\nBob", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 244, "cpu_time_ms": 240, "memory_kb": 38252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s430579263", "group_id": "codeNet:p03804", "input_text": "fun main(args: Array) {\n abc054b()\n}\n\nfun abc054b() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = (1..n).map { readLine()!! }\n val bList = (1..m).map { readLine()!! }\n\n // 適当に全探索してみる\n for (i in 0..n - m) {\n for (j in 0..n - m) {\n val aTrim = aList.slice(i until i + m).map { it.substring(j until j + m) }\n if (aTrim == bList) return println(\"Yes\")\n }\n }\n\n println(\"No\")\n}\n", "language": "Kotlin", "metadata": {"date": 1571613079, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Kotlin/s430579263.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430579263", "user_id": "u139478771"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n abc054b()\n}\n\nfun abc054b() {\n val (n, m) = readLine()!!.split(\" \").map { it.toInt() }\n val aList = (1..n).map { readLine()!! }\n val bList = (1..m).map { readLine()!! }\n\n // 適当に全探索してみる\n for (i in 0..n - m) {\n for (j in 0..n - m) {\n val aTrim = aList.slice(i until i + m).map { it.substring(j until j + m) }\n if (aTrim == bList) return println(\"Yes\")\n }\n }\n\n println(\"No\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 486, "cpu_time_ms": 311, "memory_kb": 37820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s195817798", "group_id": "codeNet:p03804", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.next().toInt()\n val m = sc.next().toInt()\n val aList = (0 until n).map { sc.next() }\n val bList = (0 until m).map { sc.next() }\n println(problem54b(n, m, aList, bList))\n}\n\nfun problem54b(n: Int, m: Int, aList:List, bList:List): String {\n val bListY = bList.size\n val bListX = bList[0].length\n aList.forEachIndexed { i, s ->\n if (i + bListY - 1 > aList.size - 1) return@forEachIndexed\n (0 until aList[0].length).forEach { j ->\n if (j + bListX > aList[0].length - 1) return@forEach\n val subSquare = aList.drop(i).map { it.substring(j, j + bListX) }.take(bListY)\n if (subSquare == bList) return \"Yes\"\n }\n }\n return \"No\"\n}", "language": "Kotlin", "metadata": {"date": 1564273293, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Kotlin/s195817798.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s195817798", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.next().toInt()\n val m = sc.next().toInt()\n val aList = (0 until n).map { sc.next() }\n val bList = (0 until m).map { sc.next() }\n println(problem54b(n, m, aList, bList))\n}\n\nfun problem54b(n: Int, m: Int, aList:List, bList:List): String {\n val bListY = bList.size\n val bListX = bList[0].length\n aList.forEachIndexed { i, s ->\n if (i + bListY - 1 > aList.size - 1) return@forEachIndexed\n (0 until aList[0].length).forEach { j ->\n if (j + bListX > aList[0].length - 1) return@forEach\n val subSquare = aList.drop(i).map { it.substring(j, j + bListX) }.take(bListY)\n if (subSquare == bList) return \"Yes\"\n }\n }\n return \"No\"\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 816, "cpu_time_ms": 248, "memory_kb": 31644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s431827792", "group_id": "codeNet:p03805", "input_text": "\nvar visited = mutableListOf()\nvar pathList = Array(100) {arrayOfNulls(100)}\nvar n = 0\nvar m = 0\n\nfun main(args: Array) {\n\n val total = readLine()?.split(\" \").orEmpty()\n n = total[0].toInt()\n m = total[1].toInt()\n\n var k = 0\n while(k < 100){\n var l = 0\n while(l < 100){\n pathList[k][l] = false\n l++\n }\n k++\n }\n\n var i = 0\n while(i < m){\n var path = readLine()?.split(\" \").orEmpty()\n pathList[path[0].toInt() - 1][path[1].toInt() - 1] = true\n pathList[path[1].toInt() - 1][path[0].toInt() - 1] = true\n i++\n }\n\n\n for(j in 1 .. n){\n visited.add(false)\n }\n //----------------------------------------------------------\n\n println(dfs(0,0))\n\n //----------------------------------------------------------\n\n\n}\n\nfun dfs( now: Int, depth: Int): Int {\n if (visited[now]) {\n return 0\n }\n if (depth == n - 1) {\n return 1\n }\n visited[now] = true\n var totalPaths = 0\n\n for (h in 0 until n) {\n if (pathList[now][h]!!) {\n totalPaths += dfs(h, depth + 1)\n }\n }\n visited[now] = false\n return totalPaths\n}\n\n\n", "language": "Kotlin", "metadata": {"date": 1584046149, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03805.html", "problem_id": "p03805", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03805/input.txt", "sample_output_relpath": "derived/input_output/data/p03805/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03805/Kotlin/s431827792.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s431827792", "user_id": "u430710262"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nvar visited = mutableListOf()\nvar pathList = Array(100) {arrayOfNulls(100)}\nvar n = 0\nvar m = 0\n\nfun main(args: Array) {\n\n val total = readLine()?.split(\" \").orEmpty()\n n = total[0].toInt()\n m = total[1].toInt()\n\n var k = 0\n while(k < 100){\n var l = 0\n while(l < 100){\n pathList[k][l] = false\n l++\n }\n k++\n }\n\n var i = 0\n while(i < m){\n var path = readLine()?.split(\" \").orEmpty()\n pathList[path[0].toInt() - 1][path[1].toInt() - 1] = true\n pathList[path[1].toInt() - 1][path[0].toInt() - 1] = true\n i++\n }\n\n\n for(j in 1 .. n){\n visited.add(false)\n }\n //----------------------------------------------------------\n\n println(dfs(0,0))\n\n //----------------------------------------------------------\n\n\n}\n\nfun dfs( now: Int, depth: Int): Int {\n if (visited[now]) {\n return 0\n }\n if (depth == n - 1) {\n return 1\n }\n visited[now] = true\n var totalPaths = 0\n\n for (h in 0 until n) {\n if (pathList[now][h]!!) {\n totalPaths += dfs(h, depth + 1)\n }\n }\n visited[now] = false\n return totalPaths\n}\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i) {\n class Drug(a: Int, b: Int, val cost: Int, ma: Int, mb: Int) { // 1≦ai,bi≦10, 1≦ci≦100\n val excess = a * mb - b * ma\n }\n\n val (n, drugs) = Scanner(System.`in`).use {\n val (n, ma, mb) = Triple(it.nextInt(), it.nextInt(), it.nextInt()) // 1≦N≦40 1≦Ma,Mb≦10\n val drugs: List = Array(n) {n ->\n Drug(it.nextInt(), it.nextInt(), it.nextInt(), ma, mb)\n }.toList()\n\n n to drugs\n }\n\n val maximumCost = drugs.sumBy { it.cost }// + 1 // N * c <= 40 *100\n // 初期条件: memo[0] = setOf(0)\n val zeroSet = emptySet()\n val initialMemo: List> = Array(maximumCost, {zeroSet}).toList()//.apply{ this[0] = setOf(0) }.toList()\n // 漸化式: cell[i+1][c] = cell[i][c] + cell[i][c - drugs[i+1].cost].map{ + drugs[i+1].excess}\n val excessMemo = (0 until n).fold(initialMemo) { memo, i ->\n // cost == 0 生成量0で目的を満たさないので判定にかけない。\n (0 until memo.size).asSequence().map {cost -> // 先頭を除いたので、cost は実際のコストより1少ない。\n when {\n cost - drugs[i].cost < -1 -> memo[cost]\n cost - drugs[i].cost == -1 -> memo[cost] + setOf(drugs[i].excess)\n // 新しいオブジェクトが生成されるので、変更されたnextMemoの要素をを誤ってmemoの要素として参照することはない。\n else -> memo[cost] + memo[cost - drugs[i].cost].map{ it + drugs[i].excess }\n }\n }.takeWhile { 0 !in it }.toList() // 条件を満たすなら、それ以上のcostについては考慮する必要がない。\n // これには条件を満たすcost自身が含まれない。\n }\n\n //条件を満たすものが含まれない分、sizeはlastIndexより1大きいので正解になる。\n println(if (excessMemo.size == maximumCost) -1 else excessMemo.size + 1) // 先頭を除いた分を足す。\n}\n", "language": "Kotlin", "metadata": {"date": 1487172824, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03806.html", "problem_id": "p03806", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03806/input.txt", "sample_output_relpath": "derived/input_output/data/p03806/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03806/Kotlin/s703942259.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s703942259", "user_id": "u749576000"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\n/**\n * タイプAの物質とタイプBの物質の混合比が Ma:Mb\n * sum(a_)*mb = sum(b_)*ma\n * よって、a * mb - b * maの合計が0になる組み合わせを探す。\n * cとnについての動的計画法で行う。\n *\n * 発散するかに見えるが、\n * -100 < a * mb - b * ma < 100\n * costの上限は、N * c <= 40 *100\n * 分量の状態は200*40以下\n * で間に合いそう。\n */\nfun main(args: Array) {\n class Drug(a: Int, b: Int, val cost: Int, ma: Int, mb: Int) { // 1≦ai,bi≦10, 1≦ci≦100\n val excess = a * mb - b * ma\n }\n\n val (n, drugs) = Scanner(System.`in`).use {\n val (n, ma, mb) = Triple(it.nextInt(), it.nextInt(), it.nextInt()) // 1≦N≦40 1≦Ma,Mb≦10\n val drugs: List = Array(n) {n ->\n Drug(it.nextInt(), it.nextInt(), it.nextInt(), ma, mb)\n }.toList()\n\n n to drugs\n }\n\n val maximumCost = drugs.sumBy { it.cost }// + 1 // N * c <= 40 *100\n // 初期条件: memo[0] = setOf(0)\n val zeroSet = emptySet()\n val initialMemo: List> = Array(maximumCost, {zeroSet}).toList()//.apply{ this[0] = setOf(0) }.toList()\n // 漸化式: cell[i+1][c] = cell[i][c] + cell[i][c - drugs[i+1].cost].map{ + drugs[i+1].excess}\n val excessMemo = (0 until n).fold(initialMemo) { memo, i ->\n // cost == 0 生成量0で目的を満たさないので判定にかけない。\n (0 until memo.size).asSequence().map {cost -> // 先頭を除いたので、cost は実際のコストより1少ない。\n when {\n cost - drugs[i].cost < -1 -> memo[cost]\n cost - drugs[i].cost == -1 -> memo[cost] + setOf(drugs[i].excess)\n // 新しいオブジェクトが生成されるので、変更されたnextMemoの要素をを誤ってmemoの要素として参照することはない。\n else -> memo[cost] + memo[cost - drugs[i].cost].map{ it + drugs[i].excess }\n }\n }.takeWhile { 0 !in it }.toList() // 条件を満たすなら、それ以上のcostについては考慮する必要がない。\n // これには条件を満たすcost自身が含まれない。\n }\n\n //条件を満たすものが含まれない分、sizeはlastIndexより1大きいので正解になる。\n println(if (excessMemo.size == maximumCost) -1 else excessMemo.size + 1) // 先頭を除いた分を足す。\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nDolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n\nHe does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy.\n\nThe pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock.\n\nThe package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan).\n\nDolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C.\n\nFind the minimum amount of money required to generate the substance C.\n\nIf it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.\n\nConstraints\n\n1≦N≦40\n\n1≦a_i,b_i≦10\n\n1≦c_i≦100\n\n1≦M_a,M_b≦10\n\ngcd(M_a,M_b)=1\n\na_i, b_i, c_i, M_a and M_b are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M_a M_b\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print -1 instead.\n\nSample Input 1\n\n3 1 1\n1 2 1\n2 1 2\n3 3 10\n\nSample Output 1\n\n3\n\nThe amount of money spent will be minimized by purchasing the packages of chemicals 1 and 2.\n\nIn this case, the mixture of the purchased chemicals will contain 3 grams of the substance A and 3 grams of the substance B, which are in the desired ratio: 3:3=1:1.\n\nThe total price of these packages is 3 yen.\n\nSample Input 2\n\n1 1 10\n10 10 10\n\nSample Output 2\n\n-1\n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing any combination of the packages. Thus, the output should be -1.", "sample_input": "3 1 1\n1 2 1\n2 1 2\n3 3 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03806", "source_text": "Score : 400 points\n\nProblem Statement\n\nDolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n\nHe does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy.\n\nThe pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock.\n\nThe package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan).\n\nDolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C.\n\nFind the minimum amount of money required to generate the substance C.\n\nIf it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.\n\nConstraints\n\n1≦N≦40\n\n1≦a_i,b_i≦10\n\n1≦c_i≦100\n\n1≦M_a,M_b≦10\n\ngcd(M_a,M_b)=1\n\na_i, b_i, c_i, M_a and M_b are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M_a M_b\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print -1 instead.\n\nSample Input 1\n\n3 1 1\n1 2 1\n2 1 2\n3 3 10\n\nSample Output 1\n\n3\n\nThe amount of money spent will be minimized by purchasing the packages of chemicals 1 and 2.\n\nIn this case, the mixture of the purchased chemicals will contain 3 grams of the substance A and 3 grams of the substance B, which are in the desired ratio: 3:3=1:1.\n\nThe total price of these packages is 3 yen.\n\nSample Input 2\n\n1 1 10\n10 10 10\n\nSample Output 2\n\n-1\n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing any combination of the packages. Thus, the output should be -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2462, "cpu_time_ms": 2102, "memory_kb": 165724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s095228110", "group_id": "codeNet:p03807", "input_text": "import java.util.NoSuchElementException\n\nfun main(args: Array) = FastScanner().run {\n val n = nextInt()\n val a = LongArray(n){nextLong()}\n println(if (a.count { it % 2 != 0L } % 2 != 0) {\"NO\"} else {\"YES\"})\n}\n\nclass FastScanner {\n private val printable = 33..126\n val `in` = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = `in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun nextDouble(): Double {\n return next().toDouble()\n }\n}", "language": "Kotlin", "metadata": {"date": 1564783653, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03807.html", "problem_id": "p03807", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03807/input.txt", "sample_output_relpath": "derived/input_output/data/p03807/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03807/Kotlin/s095228110.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s095228110", "user_id": "u095834727"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.NoSuchElementException\n\nfun main(args: Array) = FastScanner().run {\n val n = nextInt()\n val a = LongArray(n){nextLong()}\n println(if (a.count { it % 2 != 0L } % 2 != 0) {\"NO\"} else {\"YES\"})\n}\n\nclass FastScanner {\n private val printable = 33..126\n val `in` = System.`in`\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n fun hasNextByte(): Boolean {\n if (ptr < buflen) {\n return true\n } else {\n ptr = 0\n buflen = `in`.read(buffer)\n if (buflen <= 0) {\n return false\n }\n }\n return true\n }\n fun readByte(): Byte {\n return if (hasNextByte()) buffer[ptr++] else return -1\n }\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n fun next(): String {\n if (!hasNext()) throw NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n fun nextLong(): Long {\n if (!hasNext()) throw NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n fun nextInt(): Int {\n val nl = nextLong()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n fun nextDouble(): Double {\n return next().toDouble()\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\nSelect a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n\nThen, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.\n\nDetermine whether it is possible to have only one integer on the blackboard.\n\nConstraints\n\n2 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYES\n\nIt is possible to have only one integer on the blackboard, as follows:\n\nErase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.\n\nErase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\nNO", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03807", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\nSelect a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n\nThen, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.\n\nDetermine whether it is possible to have only one integer on the blackboard.\n\nConstraints\n\n2 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYES\n\nIt is possible to have only one integer on the blackboard, as follows:\n\nErase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.\n\nErase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2121, "cpu_time_ms": 199, "memory_kb": 31528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s890444043", "group_id": "codeNet:p03813", "input_text": "fun main(args: Array) {\n val (x) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (x < 1200) {\n println(\"ABC\")\n } else {\n println(\"ARC\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1593291943, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03813.html", "problem_id": "p03813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03813/input.txt", "sample_output_relpath": "derived/input_output/data/p03813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03813/Kotlin/s890444043.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890444043", "user_id": "u621958170"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "fun main(args: Array) {\n val (x) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (x < 1200) {\n println(\"ABC\")\n } else {\n println(\"ARC\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "sample_input": "1000\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03813", "source_text": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 108, "memory_kb": 36344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s809010782", "group_id": "codeNet:p03813", "input_text": "fun main(args: Array) {\n println(if(readLine()!!.toInt() < 1200) \"ABC\" else \"ARC\")\n}", "language": "Kotlin", "metadata": {"date": 1556944361, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03813.html", "problem_id": "p03813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03813/input.txt", "sample_output_relpath": "derived/input_output/data/p03813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03813/Kotlin/s809010782.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s809010782", "user_id": "u782685137"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "fun main(args: Array) {\n println(if(readLine()!!.toInt() < 1200) \"ABC\" else \"ARC\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "sample_input": "1000\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03813", "source_text": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 205, "memory_kb": 29800}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s079976724", "group_id": "codeNet:p03818", "input_text": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val n = readInteger()\n val aList = readIntegerList()\n val countMap = elementCountMap(aList)\n\n var tmp = 0\n for (c in countMap.values) {\n if (c > 1) {\n tmp += (c - 1)\n }\n }\n\n if (tmp % 2 == 0) {\n println(aList.size - tmp)\n } else {\n println(aList.size - tmp - 1)\n }\n}\n\n/**\n * O(n)\n */\nfun elementCountMap(list: List): Map {\n val countMap = mutableMapOf()\n for (e in list) {\n countMap[e] = (countMap[e] ?: 0) + 1\n }\n return countMap\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "language": "Kotlin", "metadata": {"date": 1586095615, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03818.html", "problem_id": "p03818", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03818/input.txt", "sample_output_relpath": "derived/input_output/data/p03818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03818/Kotlin/s079976724.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079976724", "user_id": "u784448849"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun main(args: Array) {\n PrintWriter(System.out).use { out ->\n solve(out)\n out.flush()\n }\n}\n\nfun solve(out: PrintWriter) {\n val n = readInteger()\n val aList = readIntegerList()\n val countMap = elementCountMap(aList)\n\n var tmp = 0\n for (c in countMap.values) {\n if (c > 1) {\n tmp += (c - 1)\n }\n }\n\n if (tmp % 2 == 0) {\n println(aList.size - tmp)\n } else {\n println(aList.size - tmp - 1)\n }\n}\n\n/**\n * O(n)\n */\nfun elementCountMap(list: List): Map {\n val countMap = mutableMapOf()\n for (e in list) {\n countMap[e] = (countMap[e] ?: 0) + 1\n }\n return countMap\n}\n\nfun readInteger() = readLine()!!.toInt()\nfun readLong() = readLine()!!.toLong()\nfun readStringList() = readLine()!!.split(\" \")\nfun readIntegerList() = readStringList().map(String::toInt)\nfun readLongList() = readStringList().map(String::toLong)\nfun readDoubleList() = readStringList().map(String::toDouble)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "sample_input": "5\n1 2 1 3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03818", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1028, "cpu_time_ms": 547, "memory_kb": 56140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s963359415", "group_id": "codeNet:p03818", "input_text": "\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map(String::toInt)\n val max = aList.max()!!\n val map = IntArray(max+1) { 0 }\n aList.forEach { map[it]++ }\n (1..max).forEach { map[it] = Math.max(map[it] - 1, 0) }\n val sum = map.sum()\n if (sum % 2 == 0) {\n println(n - sum)\n } else {\n println(n - sum - 1)\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1575400329, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03818.html", "problem_id": "p03818", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03818/input.txt", "sample_output_relpath": "derived/input_output/data/p03818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03818/Kotlin/s963359415.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963359415", "user_id": "u099066216"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nfun main(args: Array) {\n val n = readLine()!!.toInt()\n val aList = readLine()!!.split(' ').map(String::toInt)\n val max = aList.max()!!\n val map = IntArray(max+1) { 0 }\n aList.forEach { map[it]++ }\n (1..max).forEach { map[it] = Math.max(map[it] - 1, 0) }\n val sum = map.sum()\n if (sum % 2 == 0) {\n println(n - sum)\n } else {\n println(n - sum - 1)\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "sample_input": "5\n1 2 1 3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03818", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 496, "memory_kb": 51884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s721597061", "group_id": "codeNet:p03821", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val ab = (1..n).map { Pair(sc.nextLong(), sc.nextLong()) }\n\n var count = 0L\n for (i in n-1 downTo 0) {\n val abi = ab[i]\n val a = abi.first\n val b = abi.second\n\n val aa = a + count\n val tmp = aa % b\n if (tmp == 0L) {\n continue\n }\n count += b - tmp\n }\n\n\n println(count)\n}\n", "language": "Kotlin", "metadata": {"date": 1598550113, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03821.html", "problem_id": "p03821", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03821/input.txt", "sample_output_relpath": "derived/input_output/data/p03821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03821/Kotlin/s721597061.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721597061", "user_id": "u323522006"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextInt()\n val ab = (1..n).map { Pair(sc.nextLong(), sc.nextLong()) }\n\n var count = 0L\n for (i in n-1 downTo 0) {\n val abi = ab[i]\n val a = abi.first\n val b = abi.second\n\n val aa = a + count\n val tmp = aa % b\n if (tmp == 0L) {\n continue\n }\n count += b - tmp\n }\n\n\n println(count)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are an integer sequence A_1,...,A_N consisting of N terms, and N buttons.\nWhen the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons some number of times so that for every i, A_i will be a multiple of B_i.\n\nFind the minimum number of times Takahashi will press the buttons.\n\nConstraints\n\nAll input values are integers.\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\n1 ≦ B_i ≦ 10^9(1 ≦ i ≦ N)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint an integer representing the minimum number of times Takahashi will press the buttons.\n\nSample Input 1\n\n3\n3 5\n2 7\n9 4\n\nSample Output 1\n\n7\n\nPress the first button twice, the second button twice and the third button three times.\n\nSample Input 2\n\n7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n\nSample Output 2\n\n22", "sample_input": "3\n3 5\n2 7\n9 4\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03821", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are an integer sequence A_1,...,A_N consisting of N terms, and N buttons.\nWhen the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons some number of times so that for every i, A_i will be a multiple of B_i.\n\nFind the minimum number of times Takahashi will press the buttons.\n\nConstraints\n\nAll input values are integers.\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\n1 ≦ B_i ≦ 10^9(1 ≦ i ≦ N)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint an integer representing the minimum number of times Takahashi will press the buttons.\n\nSample Input 1\n\n3\n3 5\n2 7\n9 4\n\nSample Output 1\n\n7\n\nPress the first button twice, the second button twice and the third button three times.\n\nSample Input 2\n\n7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n\nSample Output 2\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 412, "cpu_time_ms": 591, "memory_kb": 68348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s364640191", "group_id": "codeNet:p03821", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ab = (1..n).map { readLine()!!.split(\" \").map { it.toLong() } }.reversed()\n\n var sum = 0L\n ab.map {\n val (a,b) = it\n val num = sum+a\n val inc = if(num%b==0L) 0 else b-num%b\n sum += inc\n inc\n }.sum().let { println(it) }\n}", "language": "Kotlin", "metadata": {"date": 1561330444, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03821.html", "problem_id": "p03821", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03821/input.txt", "sample_output_relpath": "derived/input_output/data/p03821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03821/Kotlin/s364640191.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s364640191", "user_id": "u914096045"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val ab = (1..n).map { readLine()!!.split(\" \").map { it.toLong() } }.reversed()\n\n var sum = 0L\n ab.map {\n val (a,b) = it\n val num = sum+a\n val inc = if(num%b==0L) 0 else b-num%b\n sum += inc\n inc\n }.sum().let { println(it) }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are an integer sequence A_1,...,A_N consisting of N terms, and N buttons.\nWhen the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons some number of times so that for every i, A_i will be a multiple of B_i.\n\nFind the minimum number of times Takahashi will press the buttons.\n\nConstraints\n\nAll input values are integers.\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\n1 ≦ B_i ≦ 10^9(1 ≦ i ≦ N)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint an integer representing the minimum number of times Takahashi will press the buttons.\n\nSample Input 1\n\n3\n3 5\n2 7\n9 4\n\nSample Output 1\n\n7\n\nPress the first button twice, the second button twice and the third button three times.\n\nSample Input 2\n\n7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n\nSample Output 2\n\n22", "sample_input": "3\n3 5\n2 7\n9 4\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03821", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are an integer sequence A_1,...,A_N consisting of N terms, and N buttons.\nWhen the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons some number of times so that for every i, A_i will be a multiple of B_i.\n\nFind the minimum number of times Takahashi will press the buttons.\n\nConstraints\n\nAll input values are integers.\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\n1 ≦ B_i ≦ 10^9(1 ≦ i ≦ N)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint an integer representing the minimum number of times Takahashi will press the buttons.\n\nSample Input 1\n\n3\n3 5\n2 7\n9 4\n\nSample Output 1\n\n7\n\nPress the first button twice, the second button twice and the third button three times.\n\nSample Input 2\n\n7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n\nSample Output 2\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 667, "memory_kb": 65996}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s997044100", "group_id": "codeNet:p03826", "input_text": "fun main(args: Array) {\n val (a, b, c, d) = readLine()!!.split(\" \").map(String::toInt)\n val ab = a * b\n val cd = c * d\n println(Math.max(ab, cd))\n}\n", "language": "Kotlin", "metadata": {"date": 1549337796, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03826.html", "problem_id": "p03826", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03826/input.txt", "sample_output_relpath": "derived/input_output/data/p03826/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03826/Kotlin/s997044100.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997044100", "user_id": "u051841332"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c, d) = readLine()!!.split(\" \").map(String::toInt)\n val ab = a * b\n val cd = c * d\n println(Math.max(ab, cd))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "sample_input": "3 5 2 7\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03826", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 168, "cpu_time_ms": 239, "memory_kb": 35944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s828277800", "group_id": "codeNet:p03836", "input_text": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (sx, sy, tx, ty) = nextIntList()\n val dx = tx - sx\n val dy = ty - sy\n val cx = if (dx > 0) \"R\" else \"L\"\n val cy = if (dy > 0) \"U\" else \"D\"\n val cxr = if (dx > 0) \"L\" else \"R\"\n val cyr = if (dy > 0) \"D\" else \"U\"\n print(cx.repeat(dx) + cy.repeat(dy) + cxr.repeat(dx) + cyr.repeat(dy))\n print(cyr + cx.repeat(dx + 1) + cy.repeat(dy + 1) + cxr + cy + cxr.repeat(dx + 1) + cyr.repeat(dy + 1) + cx)\n println()\n}\n", "language": "Kotlin", "metadata": {"date": 1591550357, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03836/input.txt", "sample_output_relpath": "derived/input_output/data/p03836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03836/Kotlin/s828277800.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s828277800", "user_id": "u860789370"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "import java.io.PrintWriter\n\nfun next() = readLine()!!\nfun nextInt() = next().toInt()\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun nextList() = next().split(\" \")\nfun nextIntList() = nextList().map(String::toInt)\nfun nextLongList() = nextList().map(String::toLong)\nfun nextDoubleList() = nextList().map(String::toDouble)\n\nval pw = PrintWriter(System.out)\nfun print(s: Any = \"\") = pw.print(s)\nfun println(s: Any = \"\") = pw.println(s)\n\nfun Iterable.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\nfun Array.join(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\") = joinToString(separator, prefix, postfix)\n\nfun main(args: Array) {\n main()\n pw.flush()\n}\n\nfun main() {\n val (sx, sy, tx, ty) = nextIntList()\n val dx = tx - sx\n val dy = ty - sy\n val cx = if (dx > 0) \"R\" else \"L\"\n val cy = if (dy > 0) \"U\" else \"D\"\n val cxr = if (dx > 0) \"L\" else \"R\"\n val cyr = if (dy > 0) \"D\" else \"U\"\n print(cx.repeat(dx) + cy.repeat(dy) + cxr.repeat(dx) + cyr.repeat(dy))\n print(cyr + cx.repeat(dx + 1) + cy.repeat(dy + 1) + cxr + cy + cxr.repeat(dx + 1) + cyr.repeat(dy + 1) + cx)\n println()\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "sample_input": "0 0 1 2\n"}, "reference_outputs": ["UURDDLLUUURRDRDDDLLU\n"], "source_document_id": "p03836", "source_text": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1284, "cpu_time_ms": 254, "memory_kb": 37672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s976756144", "group_id": "codeNet:p03837", "input_text": "fun main(args: Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val dist = Array(n){IntArray(n){99999999}}\n val edge =(1..m).map{\n val (a,b,c) = readLine()!!.split(\" \").map { it.toInt() }\n dist[a-1][b-1]=c\n dist[b-1][a-1]=c\n c*n*n+(a-1)*n+(b-1)\n }\n for (i in 0..n-1)dist[i][i]=0\n for(k in 0..n-1)for(i in 0..n-1)for(j in 0..n-1)\n dist[i][j] = Math.min(dist[i][j], dist[i][k]+dist[k][j])\n\n// dist.forEach { println(it.joinToString(\",\")) }\n val ans = edge.count{\n val u=it%(n*n)/n\n val v=it%n\n val w=it/(n*n)\n for(s in 0..n-1)for(t in 0..n-1){\n if(dist[s][u]+w+dist[v][t]==dist[s][t]) return@count false\n }\n return@count true\n }\n\n println(ans)\n}", "language": "Kotlin", "metadata": {"date": 1544499837, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03837/input.txt", "sample_output_relpath": "derived/input_output/data/p03837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03837/Kotlin/s976756144.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976756144", "user_id": "u914096045"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) {\n val (n,m) = readLine()!!.split(\" \").map { it.toInt() }\n val dist = Array(n){IntArray(n){99999999}}\n val edge =(1..m).map{\n val (a,b,c) = readLine()!!.split(\" \").map { it.toInt() }\n dist[a-1][b-1]=c\n dist[b-1][a-1]=c\n c*n*n+(a-1)*n+(b-1)\n }\n for (i in 0..n-1)dist[i][i]=0\n for(k in 0..n-1)for(i in 0..n-1)for(j in 0..n-1)\n dist[i][j] = Math.min(dist[i][j], dist[i][k]+dist[k][j])\n\n// dist.forEach { println(it.joinToString(\",\")) }\n val ans = edge.count{\n val u=it%(n*n)/n\n val v=it%n\n val w=it/(n*n)\n for(s in 0..n-1)for(t in 0..n-1){\n if(dist[s][u]+w+dist[v][t]==dist[s][t]) return@count false\n }\n return@count true\n }\n\n println(ans)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val list = mutableListOf()\n for (i in 0 until n) {\n val a = scanner.nextInt()\n list.add(i, a)\n }\n\n val m = scanner.nextInt()\n for (i in 0 until m){\n val drink = scanner.nextInt()\n val base = list[i]\n list[i] = scanner.nextInt()\n System.out.print(list.sum())\n list[i] = base\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1565962997, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03845.html", "problem_id": "p03845", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03845/input.txt", "sample_output_relpath": "derived/input_output/data/p03845/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03845/Kotlin/s718512494.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s718512494", "user_id": "u482066761"}, "prompt_components": {"gold_output": "6\n9\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array) {\n val scanner = Scanner(System.`in`)\n val n = scanner.nextInt()\n val list = mutableListOf()\n for (i in 0 until n) {\n val a = scanner.nextInt()\n list.add(i, a)\n }\n\n val m = scanner.nextInt()\n for (i in 0 until m){\n val drink = scanner.nextInt()\n val base = list[i]\n list[i] = scanner.nextInt()\n System.out.print(list.sum())\n list[i] = base\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "sample_input": "3\n2 1 4\n2\n1 1\n2 3\n"}, "reference_outputs": ["6\n9\n"], "source_document_id": "p03845", "source_text": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 473, "cpu_time_ms": 224, "memory_kb": 31400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s872594077", "group_id": "codeNet:p03846", "input_text": "fun main(arg: Array) {\n val N = nextInt()\n val A = listOfInt().sorted()\n var p: Int\n var q: Int\n if (N % 2 != 0) {\n if (A[0] != 0) return println(0)\n p = 1\n q = 2\n } else {\n if (A[0] != 1 || A[1] != 1) return println(0)\n p = 2\n q = 3\n }\n var ans = 1L\n while (p < N) {\n if (A[p] != q || A[p + 1] != q) return println(0)\n ans = ans * 2 % 1000000007\n p += 2\n q += 2\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }\nfun listOfLong() = listOfString().map(String::toLong)\nfun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }\nfun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }\n", "language": "Kotlin", "metadata": {"date": 1586231063, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/Kotlin/s872594077.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s872594077", "user_id": "u043150661"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main(arg: Array) {\n val N = nextInt()\n val A = listOfInt().sorted()\n var p: Int\n var q: Int\n if (N % 2 != 0) {\n if (A[0] != 0) return println(0)\n p = 1\n q = 2\n } else {\n if (A[0] != 1 || A[1] != 1) return println(0)\n p = 2\n q = 3\n }\n var ans = 1L\n while (p < N) {\n if (A[p] != q || A[p + 1] != q) return println(0)\n ans = ans * 2 % 1000000007\n p += 2\n q += 2\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset\nfun nextLong() = next().toLong()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }\nfun listOfLong() = listOfString().map(String::toLong)\nfun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }\nfun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1082, "cpu_time_ms": 785, "memory_kb": 54140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s749186726", "group_id": "codeNet:p03846", "input_text": "import java.math.BigDecimal\nimport java.util.*\n\nval mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val aList = mutableListOf()\n for (i in 0 until n) {\n aList.add(sc.nextLong())\n }\n val isOdd = n % 2 != 0L\n if (isOdd && !aList.contains(0)) {\n println(0)\n return\n }\n if (!isOdd && aList.contains(0)) {\n println(0)\n return\n }\n\n var bList = mutableListOf()\n for (i in 1..n / 2) {\n bList.add(n - i * 2 + 1)\n }\n val reversed = bList.reversed().toMutableList()\n if (n % 2 != 0L) {\n reversed.add(0, 0)\n }\n bList = (bList + reversed).toMutableList()\n\n if (aList.sorted() != bList.sorted()) {\n println(0)\n return\n }\n val bigN = BigDecimal.valueOf(2)\n val ans = bigN.pow( (n / 2).toInt()).remainder(BigDecimal(mod))\n println(ans.toLong())\n}\n", "language": "Kotlin", "metadata": {"date": 1563482412, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/Kotlin/s749186726.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749186726", "user_id": "u073232808"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.math.BigDecimal\nimport java.util.*\n\nval mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val aList = mutableListOf()\n for (i in 0 until n) {\n aList.add(sc.nextLong())\n }\n val isOdd = n % 2 != 0L\n if (isOdd && !aList.contains(0)) {\n println(0)\n return\n }\n if (!isOdd && aList.contains(0)) {\n println(0)\n return\n }\n\n var bList = mutableListOf()\n for (i in 1..n / 2) {\n bList.add(n - i * 2 + 1)\n }\n val reversed = bList.reversed().toMutableList()\n if (n % 2 != 0L) {\n reversed.add(0, 0)\n }\n bList = (bList + reversed).toMutableList()\n\n if (aList.sorted() != bList.sorted()) {\n println(0)\n return\n }\n val bigN = BigDecimal.valueOf(2)\n val ans = bigN.pow( (n / 2).toInt()).remainder(BigDecimal(mod))\n println(ans.toLong())\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 959, "cpu_time_ms": 962, "memory_kb": 57476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s800128064", "group_id": "codeNet:p03846", "input_text": "import java.util.*\n\nval mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val aList = mutableListOf()\n for (i in 0 until n) {\n aList.add(sc.nextLong())\n }\n val isOdd = n % 2 != 0L\n if (isOdd && !aList.contains(0)) {\n println(0)\n return\n }\n if (!isOdd && aList.contains(0)) {\n println(0)\n return\n }\n\n var bList = mutableListOf()\n for (i in 1..n / 2) {\n bList.add(n - i * 2 + 1)\n }\n val reversed = bList.reversed().toMutableList()\n if (n % 2 != 0L) {\n reversed.add(0, 0)\n }\n bList = (bList + reversed).toMutableList()\n\n if (aList.sorted() != bList.sorted()) {\n println(0)\n return\n }\n\n val ans = Math.pow(2.0, (n / 2).toDouble() % mod)\n println(ans.toLong())\n}", "language": "Kotlin", "metadata": {"date": 1563481631, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/Kotlin/s800128064.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s800128064", "user_id": "u073232808"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nval mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val n = sc.nextLong()\n val aList = mutableListOf()\n for (i in 0 until n) {\n aList.add(sc.nextLong())\n }\n val isOdd = n % 2 != 0L\n if (isOdd && !aList.contains(0)) {\n println(0)\n return\n }\n if (!isOdd && aList.contains(0)) {\n println(0)\n return\n }\n\n var bList = mutableListOf()\n for (i in 1..n / 2) {\n bList.add(n - i * 2 + 1)\n }\n val reversed = bList.reversed().toMutableList()\n if (n % 2 != 0L) {\n reversed.add(0, 0)\n }\n bList = (bList + reversed).toMutableList()\n\n if (aList.sorted() != bList.sorted()) {\n println(0)\n return\n }\n\n val ans = Math.pow(2.0, (n / 2).toDouble() % mod)\n println(ans.toLong())\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 880, "cpu_time_ms": 928, "memory_kb": 55316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s005341612", "group_id": "codeNet:p03852", "input_text": "fun main(args: Array) {\n val S = readLine()!!\n\n if(check(S))\n println(\"YES\")\n else\n println(\"NO\")\n}\n\nfun check(s:String) : Boolean\n{\n var result : Boolean = false\n\n if(s == \"dreamer\" || s == \"dream\" || s == \"erase\" || s == \"eraser\")\n return true\n else {\n if(s.startsWith(\"dreamer\") || s.startsWith(\"dream\") || s.startsWith(\"erase\") || s.startsWith(\"eraser\"))\n {\n if(check(s.substring(7))) return true\n if(check(s.substring(5))) return true\n if(check(s.substring(5))) return true\n if(check(s.substring(6))) return true\n } \n return false\n }\n}", "language": "Kotlin", "metadata": {"date": 1591301008, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03852.html", "problem_id": "p03852", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03852/input.txt", "sample_output_relpath": "derived/input_output/data/p03852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03852/Kotlin/s005341612.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s005341612", "user_id": "u805867943"}, "prompt_components": {"gold_output": "vowel\n", "input_to_evaluate": "fun main(args: Array) {\n val S = readLine()!!\n\n if(check(S))\n println(\"YES\")\n else\n println(\"NO\")\n}\n\nfun check(s:String) : Boolean\n{\n var result : Boolean = false\n\n if(s == \"dreamer\" || s == \"dream\" || s == \"erase\" || s == \"eraser\")\n return true\n else {\n if(s.startsWith(\"dreamer\") || s.startsWith(\"dream\") || s.startsWith(\"erase\") || s.startsWith(\"eraser\"))\n {\n if(check(s.substring(7))) return true\n if(check(s.substring(5))) return true\n if(check(s.substring(5))) return true\n if(check(s.substring(6))) return true\n } \n return false\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "sample_input": "a\n"}, "reference_outputs": ["vowel\n"], "source_document_id": "p03852", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 694, "cpu_time_ms": 205, "memory_kb": 31868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s460569041", "group_id": "codeNet:p03860", "input_text": "import java.util.Scanner\n\nfun main(args:Array){\n\n val scn = Scanner(System.`in`)\n val s:String = scn.next()\n\n println(\"Atcorder\"+\" \"+s.substring(0,1)+\" \"+\"Contest\")\n\n\n\n\n\n}", "language": "Kotlin", "metadata": {"date": 1563837182, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03860.html", "problem_id": "p03860", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03860/input.txt", "sample_output_relpath": "derived/input_output/data/p03860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03860/Kotlin/s460569041.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s460569041", "user_id": "u047633233"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.util.Scanner\n\nfun main(args:Array){\n\n val scn = Scanner(System.`in`)\n val s:String = scn.next()\n\n println(\"Atcorder\"+\" \"+s.substring(0,1)+\" \"+\"Contest\")\n\n\n\n\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\n\nSnuke has decided to abbreviate the name of the contest as \"AxC\".\nHere, x is the uppercase English letter at the beginning of s.\n\nGiven the name of the contest, print the abbreviation of the name.\n\nConstraints\n\nThe length of s is between 1 and 100, inclusive.\n\nThe first character in s is an uppercase English letter.\n\nThe second and subsequent characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nAtCoder s Contest\n\nOutput\n\nPrint the abbreviation of the name of the contest.\n\nSample Input 1\n\nAtCoder Beginner Contest\n\nSample Output 1\n\nABC\n\nThe contest in which you are participating now.\n\nSample Input 2\n\nAtCoder Snuke Contest\n\nSample Output 2\n\nASC\n\nThis contest does not actually exist.\n\nSample Input 3\n\nAtCoder X Contest\n\nSample Output 3\n\nAXC", "sample_input": "AtCoder Beginner Contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03860", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\n\nSnuke has decided to abbreviate the name of the contest as \"AxC\".\nHere, x is the uppercase English letter at the beginning of s.\n\nGiven the name of the contest, print the abbreviation of the name.\n\nConstraints\n\nThe length of s is between 1 and 100, inclusive.\n\nThe first character in s is an uppercase English letter.\n\nThe second and subsequent characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nAtCoder s Contest\n\nOutput\n\nPrint the abbreviation of the name of the contest.\n\nSample Input 1\n\nAtCoder Beginner Contest\n\nSample Output 1\n\nABC\n\nThe contest in which you are participating now.\n\nSample Input 2\n\nAtCoder Snuke Contest\n\nSample Output 2\n\nASC\n\nThis contest does not actually exist.\n\nSample Input 3\n\nAtCoder X Contest\n\nSample Output 3\n\nAXC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 188, "cpu_time_ms": 174, "memory_kb": 29344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s778255990", "group_id": "codeNet:p03861", "input_text": "fun main(args: Array){\n val (a,b,x) = readLine()!!.split(\" \").map{ it.toLong()}\n\n if(a != 0L){\n System.out.println(b/x - (a-1)/x)\n } else {\n System.out.println(b/x + 1)\n }\n\n}", "language": "Kotlin", "metadata": {"date": 1599313127, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03861.html", "problem_id": "p03861", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03861/input.txt", "sample_output_relpath": "derived/input_output/data/p03861/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03861/Kotlin/s778255990.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s778255990", "user_id": "u579455624"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array){\n val (a,b,x) = readLine()!!.split(\" \").map{ it.toLong()}\n\n if(a != 0L){\n System.out.println(b/x - (a-1)/x)\n } else {\n System.out.println(b/x + 1)\n }\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "sample_input": "4 8 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03861", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 115, "memory_kb": 36524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s094255512", "group_id": "codeNet:p03864", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var b = IntArray(n) { a[it] }\n var ans = arrayOf(b[0] - x, 0).max()!!\n b[0] -= ans\n for (i in 1 until n) {\n val c = arrayOf(b[i - 1] + b[i] - x, 0).max()!!\n ans += c\n b[i] -= c\n }\n println(ans)\n}\n", "language": "Kotlin", "metadata": {"date": 1570101768, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03864.html", "problem_id": "p03864", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03864/input.txt", "sample_output_relpath": "derived/input_output/data/p03864/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03864/Kotlin/s094255512.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s094255512", "user_id": "u858748695"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val (n, x) = readLine()!!.split(\" \").map { it.toInt() }\n val a = readLine()!!.split(\" \").map { it.toInt() }\n var b = IntArray(n) { a[it] }\n var ans = arrayOf(b[0] - x, 0).max()!!\n b[0] -= ans\n for (i in 1 until n) {\n val c = arrayOf(b[i - 1] + b[i] - x, 0).max()!!\n ans += c\n b[i] -= c\n }\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\n\nSnuke can perform the following operation any number of times:\n\nChoose a box containing at least one candy, and eat one of the candies in the chosen box.\n\nHis objective is as follows:\n\nAny two neighboring boxes contain at most x candies in total.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i ≤ 10^9\n\n0 ≤ x ≤ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3 3\n2 2 2\n\nSample Output 1\n\n1\n\nEat one candy in the second box.\nThen, the number of candies in each box becomes (2, 1, 2).\n\nSample Input 2\n\n6 1\n1 6 1 2 0 4\n\nSample Output 2\n\n11\n\nFor example, eat six candies in the second box, two in the fourth box, and three in the sixth box.\nThen, the number of candies in each box becomes (1, 0, 1, 0, 0, 1).\n\nSample Input 3\n\n5 9\n3 1 4 1 5\n\nSample Output 3\n\n0\n\nThe objective is already achieved without performing operations.\n\nSample Input 4\n\n2 0\n5 5\n\nSample Output 4\n\n10\n\nAll the candies need to be eaten.", "sample_input": "3 3\n2 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03864", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\n\nSnuke can perform the following operation any number of times:\n\nChoose a box containing at least one candy, and eat one of the candies in the chosen box.\n\nHis objective is as follows:\n\nAny two neighboring boxes contain at most x candies in total.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i ≤ 10^9\n\n0 ≤ x ≤ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3 3\n2 2 2\n\nSample Output 1\n\n1\n\nEat one candy in the second box.\nThen, the number of candies in each box becomes (2, 1, 2).\n\nSample Input 2\n\n6 1\n1 6 1 2 0 4\n\nSample Output 2\n\n11\n\nFor example, eat six candies in the second box, two in the fourth box, and three in the sixth box.\nThen, the number of candies in each box becomes (1, 0, 1, 0, 0, 1).\n\nSample Input 3\n\n5 9\n3 1 4 1 5\n\nSample Output 3\n\n0\n\nThe objective is already achieved without performing operations.\n\nSample Input 4\n\n2 0\n5 5\n\nSample Output 4\n\n10\n\nAll the candies need to be eaten.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 567, "memory_kb": 72116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s496017987", "group_id": "codeNet:p03937", "input_text": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val h = sc.nextInt()\n val w = sc.nextInt()\n val a = (0 until h).map { sc.next().toCharArray() }\n println(problem002a(h, w, a))\n}\n\nfun problem002a(h: Int, w: Int, a: List): String {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if (a[i][j] != '#') continue\n if (i == 0 && j == 0) continue\n if (i == h - 1 && j == w - 1) continue\n\n val top = if (i == 0) '.' else a[i - 1][j]\n val bottom = if (i == h - 1) '.' else a[i + 1][j]\n val left = if (j == 0) '.' else a[i][j - 1]\n val right = if (j == w - 1) '.' else a[i][j + 1]\n if (right == '#' && bottom =='#') {\n return \"Impossible\"\n }\n if (listOf(top, bottom, left, right).count { it == '#' } != 2) {\n return \"Impossible\"\n }\n }\n }\n return \"Possible\"\n}", "language": "Kotlin", "metadata": {"date": 1590867761, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03937.html", "problem_id": "p03937", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03937/input.txt", "sample_output_relpath": "derived/input_output/data/p03937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03937/Kotlin/s496017987.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s496017987", "user_id": "u073232808"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n val sc = Scanner(System.`in`)\n val h = sc.nextInt()\n val w = sc.nextInt()\n val a = (0 until h).map { sc.next().toCharArray() }\n println(problem002a(h, w, a))\n}\n\nfun problem002a(h: Int, w: Int, a: List): String {\n for (i in 0 until h) {\n for (j in 0 until w) {\n if (a[i][j] != '#') continue\n if (i == 0 && j == 0) continue\n if (i == h - 1 && j == w - 1) continue\n\n val top = if (i == 0) '.' else a[i - 1][j]\n val bottom = if (i == h - 1) '.' else a[i + 1][j]\n val left = if (j == 0) '.' else a[i][j - 1]\n val right = if (j == w - 1) '.' else a[i][j + 1]\n if (right == '#' && bottom =='#') {\n return \"Impossible\"\n }\n if (listOf(top, bottom, left, right).count { it == '#' } != 2) {\n return \"Impossible\"\n }\n }\n }\n return \"Possible\"\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "sample_input": "4 5\n##...\n.##..\n..##.\n...##\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03937", "source_text": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 984, "cpu_time_ms": 206, "memory_kb": 35904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s114551213", "group_id": "codeNet:p03944", "input_text": "fun main(args: Array) {\n val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }\n val field = Array(h) { BooleanArray(w) { true } }\n repeat (n) {\n val (x, y, a) = readLine()!!.split(' ').map { it.toInt() }\n val (xmin, xmax, ymin, ymax) = when (a) {\n 1 -> listOf(0, x, 0, h)\n 2 -> listOf(x, w, 0, h)\n 3 -> listOf(0, w, 0, y)\n 4 -> listOf(0, w, y, h)\n else -> listOf()\n }\n for (i in ymin until ymax) {\n for (j in xmin until xmax) {\n field[i][j] = false\n }\n }\n }\n println(field.map{ it.count{ it } }.sum())\n}\n", "language": "Kotlin", "metadata": {"date": 1599513884, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03944.html", "problem_id": "p03944", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03944/input.txt", "sample_output_relpath": "derived/input_output/data/p03944/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03944/Kotlin/s114551213.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114551213", "user_id": "u288435405"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }\n val field = Array(h) { BooleanArray(w) { true } }\n repeat (n) {\n val (x, y, a) = readLine()!!.split(' ').map { it.toInt() }\n val (xmin, xmax, ymin, ymax) = when (a) {\n 1 -> listOf(0, x, 0, h)\n 2 -> listOf(x, w, 0, h)\n 3 -> listOf(0, w, 0, y)\n 4 -> listOf(0, w, y, h)\n else -> listOf()\n }\n for (i in ymin until ymax) {\n for (j in xmin until xmax) {\n field[i][j] = false\n }\n }\n }\n println(field.map{ it.count{ it } }.sum())\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "sample_input": "5 4 2\n2 1 1\n3 3 4\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03944", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 659, "cpu_time_ms": 195, "memory_kb": 42512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s542218514", "group_id": "codeNet:p03946", "input_text": "fun main(arg: Array) {\n val (N, T) = listOfInt()\n val A = listOfInt()\n val M = A.toIntArray()\n for (n in N - 2 downTo 0) {\n if (M[n] <= M[n + 1]) M[n] = M[n + 1]\n }\n var max = 0\n var ans = 0\n for (n in 0 until N - 1) {\n if (A[n] < M[n + 1]) {\n val m = M[n + 1] - A[n]\n if (max == m) ans += 1\n else if (max < m) {\n max = m; ans = 1\n }\n }\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n", "language": "Kotlin", "metadata": {"date": 1586373403, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03946.html", "problem_id": "p03946", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03946/input.txt", "sample_output_relpath": "derived/input_output/data/p03946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03946/Kotlin/s542218514.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s542218514", "user_id": "u043150661"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(arg: Array) {\n val (N, T) = listOfInt()\n val A = listOfInt()\n val M = A.toIntArray()\n for (n in N - 2 downTo 0) {\n if (M[n] <= M[n + 1]) M[n] = M[n + 1]\n }\n var max = 0\n var ans = 0\n for (n in 0 until N - 1) {\n if (A[n] < M[n + 1]) {\n val m = M[n + 1] - A[n]\n if (max == m) ans += 1\n else if (max < m) {\n max = m; ans = 1\n }\n }\n }\n println(ans)\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "sample_input": "3 2\n100 50 200\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03946", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 863, "cpu_time_ms": 510, "memory_kb": 53740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s978436102", "group_id": "codeNet:p03951", "input_text": "fun main(args: Array) {\n val N = nextInt()\n val S = next()\n val T = next()\n var n = 0\n while (n < N) {\n var m = N - n\n while (m > 0) {\n if (S.substring(n) == T.substring(0, m)) {\n println(N + N - m)\n return\n }\n m--\n }\n n++\n }\n println(N+n)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\n", "language": "Kotlin", "metadata": {"date": 1566679748, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03951.html", "problem_id": "p03951", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03951/input.txt", "sample_output_relpath": "derived/input_output/data/p03951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03951/Kotlin/s978436102.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s978436102", "user_id": "u043150661"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(args: Array) {\n val N = nextInt()\n val S = next()\n val T = next()\n var n = 0\n while (n < N) {\n var m = N - n\n while (m > 0) {\n if (S.substring(n) == T.substring(0, m)) {\n println(N + N - m)\n return\n }\n m--\n }\n n++\n }\n println(N+n)\n}\nfun next() = readLine()!!\nfun nextInt() = Integer.parseInt(next())\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "sample_input": "3\nabc\ncde\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03951", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 429, "cpu_time_ms": 220, "memory_kb": 33664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s244449310", "group_id": "codeNet:p03952", "input_text": "fun main(args: Array) {\n val (N, X) = listOfInt()\n if (X == 1 || X == 2 * N - 1) { println(\"No\"); return }\n println(\"Yes\")\n val A = IntArray(2 * N - 1)\n A[N - 2] = X - 1; A[N - 1] = X; A[N] = X + 1\n val B = (1..2 * N - 1).toMutableList()\n B.removeAll(listOf(X - 1, X, X + 1))\n var b = 0\n for (n in 0 until N - 2) A[n] = B[b++]\n for (n in N + 1 until 2 * N - 1) A[n] = B[b++]\n println(A.joinToString(separator = \" \"))\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n", "language": "Kotlin", "metadata": {"date": 1566682865, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03952.html", "problem_id": "p03952", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03952/input.txt", "sample_output_relpath": "derived/input_output/data/p03952/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03952/Kotlin/s244449310.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244449310", "user_id": "u043150661"}, "prompt_components": {"gold_output": "Yes\n1\n6\n3\n7\n4\n5\n2\n", "input_to_evaluate": "fun main(args: Array) {\n val (N, X) = listOfInt()\n if (X == 1 || X == 2 * N - 1) { println(\"No\"); return }\n println(\"Yes\")\n val A = IntArray(2 * N - 1)\n A[N - 2] = X - 1; A[N - 1] = X; A[N] = X + 1\n val B = (1..2 * N - 1).toMutableList()\n B.removeAll(listOf(X - 1, X, X + 1))\n var b = 0\n for (n in 0 until N - 2) A[n] = B[b++]\n for (n in N + 1 until 2 * N - 1) A[n] = B[b++]\n println(A.joinToString(separator = \" \"))\n}\n\nfun next() = readLine()!!\nfun listOfString() = next().split(\" \")\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a pyramid with N steps, built with blocks.\nThe steps are numbered 1 through N from top to bottom.\nFor each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally.\nThe pyramid is built so that the blocks at the centers of the steps are aligned vertically.\n\nA pyramid with N=4 steps\n\nSnuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.\nThen, he wrote integers into all remaining blocks, under the following rule:\n\nThe integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.\n\nWriting integers into the blocks\n\nAfterwards, he erased all integers written into the blocks.\nNow, he only remembers that the integer written into the block of step 1 was x.\n\nConstruct a permutation of (1, 2, ..., 2N-1) that could have been written into the blocks of step N, or declare that Snuke's memory is incorrect and such a permutation does not exist.\n\nConstraints\n\n2≤N≤10^5\n\n1≤x≤2N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\n\nOutput\n\nIf no permutation of (1, 2, ..., 2N-1) could have been written into the blocks of step N, print No.\n\nOtherwise, print Yes in the first line, then print 2N-1 lines in addition.\n\nThe i-th of these 2N-1 lines should contain the i-th element of a possible permutation.\n\nSample Input 1\n\n4 4\n\nSample Output 1\n\nYes\n1\n6\n3\n7\n4\n5\n2\n\nThis case corresponds to the figure in the problem statement.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\nNo\n\nNo matter what permutation was written into the blocks of step N, the integer written into the block of step 1 would be 2.", "sample_input": "4 4\n"}, "reference_outputs": ["Yes\n1\n6\n3\n7\n4\n5\n2\n"], "source_document_id": "p03952", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a pyramid with N steps, built with blocks.\nThe steps are numbered 1 through N from top to bottom.\nFor each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally.\nThe pyramid is built so that the blocks at the centers of the steps are aligned vertically.\n\nA pyramid with N=4 steps\n\nSnuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.\nThen, he wrote integers into all remaining blocks, under the following rule:\n\nThe integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.\n\nWriting integers into the blocks\n\nAfterwards, he erased all integers written into the blocks.\nNow, he only remembers that the integer written into the block of step 1 was x.\n\nConstruct a permutation of (1, 2, ..., 2N-1) that could have been written into the blocks of step N, or declare that Snuke's memory is incorrect and such a permutation does not exist.\n\nConstraints\n\n2≤N≤10^5\n\n1≤x≤2N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\n\nOutput\n\nIf no permutation of (1, 2, ..., 2N-1) could have been written into the blocks of step N, print No.\n\nOtherwise, print Yes in the first line, then print 2N-1 lines in addition.\n\nThe i-th of these 2N-1 lines should contain the i-th element of a possible permutation.\n\nSample Input 1\n\n4 4\n\nSample Output 1\n\nYes\n1\n6\n3\n7\n4\n5\n2\n\nThis case corresponds to the figure in the problem statement.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\nNo\n\nNo matter what permutation was written into the blocks of step N, the integer written into the block of step 1 would be 2.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 424, "memory_kb": 61060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s758421329", "group_id": "codeNet:p03962", "input_text": "fun main(args: Array) {\n a46(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\n\nfun a46(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val colorSet = args[0].map { it.toInt() }.toSet()\n print(colorSet.size)\n}", "language": "Kotlin", "metadata": {"date": 1540164754, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03962/input.txt", "sample_output_relpath": "derived/input_output/data/p03962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03962/Kotlin/s758421329.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s758421329", "user_id": "u227166381"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "fun main(args: Array) {\n a46(readLineList())\n}\n\nfun readLineList(): Array {\n val lineList = mutableListOf()\n while (true) {\n val line = readLine()\n if (line.isNullOrBlank()) {\n break\n } else {\n lineList.add(line!!)\n }\n }\n return lineList.toTypedArray()\n}\n\n\nfun a46(args: Array) {\n if (args.size != 1) {\n throw IllegalArgumentException()\n }\n val colorSet = args[0].map { it.toInt() }.toSet()\n print(colorSet.size)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 216, "memory_kb": 32124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s654403732", "group_id": "codeNet:p03970", "input_text": "fun main(args: Array) {\n codefestival2016qualb_a()\n}\n\nfun codefestival2016qualb_a() {\n val s = readLine()!!\n\n val cf = \"CODEFESTIVAL2016\"\n\n val answer = s.withIndex().count { it.value != cf[it.index] }\n\n println(answer)\n}\n", "language": "Kotlin", "metadata": {"date": 1576119359, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03970.html", "problem_id": "p03970", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03970/input.txt", "sample_output_relpath": "derived/input_output/data/p03970/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03970/Kotlin/s654403732.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s654403732", "user_id": "u139478771"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "fun main(args: Array) {\n codefestival2016qualb_a()\n}\n\nfun codefestival2016qualb_a() {\n val s = readLine()!!\n\n val cf = \"CODEFESTIVAL2016\"\n\n val answer = s.withIndex().count { it.value != cf[it.index] }\n\n println(answer)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to CODEFESTIVAL2016.\n\nFind the minimum number of iterations for the rewrite operation.\n\nConstraints\n\nS is 16 characters long.\n\nS consists of uppercase and lowercase alphabet letters and numerals.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nS\n\nOutput\n\nOutput an integer representing the minimum number of iterations needed for the rewrite operation.\n\nSample Input 1\n\nC0DEFESTIVAL2O16\n\nSample Output 1\n\n2\n\nThe second character 0 must be changed to O and the 14th character O changed to 0.\n\nSample Input 2\n\nFESTIVAL2016CODE\n\nSample Output 2\n\n16", "sample_input": "C0DEFESTIVAL2O16\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03970", "source_text": "Score : 100 points\n\nProblem Statement\n\nCODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to CODEFESTIVAL2016.\n\nFind the minimum number of iterations for the rewrite operation.\n\nConstraints\n\nS is 16 characters long.\n\nS consists of uppercase and lowercase alphabet letters and numerals.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nS\n\nOutput\n\nOutput an integer representing the minimum number of iterations needed for the rewrite operation.\n\nSample Input 1\n\nC0DEFESTIVAL2O16\n\nSample Output 1\n\n2\n\nThe second character 0 must be changed to O and the 14th character O changed to 0.\n\nSample Input 2\n\nFESTIVAL2016CODE\n\nSample Output 2\n\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 245, "cpu_time_ms": 210, "memory_kb": 31844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s844233883", "group_id": "codeNet:p03986", "input_text": "import java.util.*\n\nfun main(args: Array) {\n agc005a()\n}\n\n// スタック使ってみる版\nfun agc005a() {\n val x = readLine()!!.map { it == 'T' }\n\n val stack = Stack()\n x.forEach { isT ->\n if (isT) {\n if (stack.isNotEmpty() && !stack.peek()) stack.pop() else stack.push(isT)\n } else {\n stack.push(isT)\n }\n }\n\n println(stack.size)\n}\n", "language": "Kotlin", "metadata": {"date": 1573344251, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03986.html", "problem_id": "p03986", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03986/input.txt", "sample_output_relpath": "derived/input_output/data/p03986/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03986/Kotlin/s844233883.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s844233883", "user_id": "u139478771"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*\n\nfun main(args: Array) {\n agc005a()\n}\n\n// スタック使ってみる版\nfun agc005a() {\n val x = readLine()!!.map { it == 'T' }\n\n val stack = Stack()\n x.forEach { isT ->\n if (isT) {\n if (stack.isNotEmpty() && !stack.peek()) stack.pop() else stack.push(isT)\n } else {\n stack.push(isT)\n }\n }\n\n println(stack.size)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a string X, which has an even number of characters. Half the characters are S, and the other half are T.\n\nTakahashi, who hates the string ST, will perform the following operation 10^{10000} times:\n\nAmong the occurrences of ST in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing.\n\nFind the eventual length of X.\n\nConstraints\n\n2 ≦ |X| ≦ 200,000\n\nThe length of X is even.\n\nHalf the characters in X are S, and the other half are T.\n\nPartial Scores\n\nIn test cases worth 200 points, |X| ≦ 200.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the eventual length of X.\n\nSample Input 1\n\nTSTTSS\n\nSample Output 1\n\n4\n\nIn the 1-st operation, the 2-nd and 3-rd characters of TSTTSS are removed.\nX becomes TTSS, and since it does not contain ST anymore, nothing is done in the remaining 10^{10000}-1 operations.\nThus, the answer is 4.\n\nSample Input 2\n\nSSTTST\n\nSample Output 2\n\n0\n\nX will eventually become an empty string: SSTTST ⇒ STST ⇒ ST ⇒ ``.\n\nSample Input 3\n\nTSSTTTSS\n\nSample Output 3\n\n4\n\nX will become: TSSTTTSS ⇒ TSTTSS ⇒ TTSS.", "sample_input": "TSTTSS\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03986", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a string X, which has an even number of characters. Half the characters are S, and the other half are T.\n\nTakahashi, who hates the string ST, will perform the following operation 10^{10000} times:\n\nAmong the occurrences of ST in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing.\n\nFind the eventual length of X.\n\nConstraints\n\n2 ≦ |X| ≦ 200,000\n\nThe length of X is even.\n\nHalf the characters in X are S, and the other half are T.\n\nPartial Scores\n\nIn test cases worth 200 points, |X| ≦ 200.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the eventual length of X.\n\nSample Input 1\n\nTSTTSS\n\nSample Output 1\n\n4\n\nIn the 1-st operation, the 2-nd and 3-rd characters of TSTTSS are removed.\nX becomes TTSS, and since it does not contain ST anymore, nothing is done in the remaining 10^{10000}-1 operations.\nThus, the answer is 4.\n\nSample Input 2\n\nSSTTST\n\nSample Output 2\n\n0\n\nX will eventually become an empty string: SSTTST ⇒ STST ⇒ ST ⇒ ``.\n\nSample Input 3\n\nTSSTTTSS\n\nSample Output 3\n\n4\n\nX will become: TSSTTTSS ⇒ TSTTSS ⇒ TTSS.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 412, "cpu_time_ms": 310, "memory_kb": 38956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s193642452", "group_id": "codeNet:p03988", "input_text": "fun main(args: Array) {\n readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val mn = a.min()!!\n val mx = a.max()!!\n val c = a.count { it == mn }\n var ans = true\n if (mn == 1) {\n if (c == 2) {\n if (mn != mx) ans = false\n } else {\n if (c > 2 || mn * 2 != mx) ans = false\n }\n } else {\n if (c == 1) {\n if (2 * mn != mx) ans = false\n } else if (c == 2) {\n if (2 * mn - 1 != mx) ans = false\n } else {\n ans = false\n }\n for (i in mn + 1..mx) {\n if (a.count { it == i } < 2) ans = false\n }\n }\n println(if (ans) \"Possible\" else \"Impossible\")\n}\n", "language": "Kotlin", "metadata": {"date": 1570249103, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03988.html", "problem_id": "p03988", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03988/input.txt", "sample_output_relpath": "derived/input_output/data/p03988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03988/Kotlin/s193642452.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s193642452", "user_id": "u858748695"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "fun main(args: Array) {\n readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val mn = a.min()!!\n val mx = a.max()!!\n val c = a.count { it == mn }\n var ans = true\n if (mn == 1) {\n if (c == 2) {\n if (mn != mx) ans = false\n } else {\n if (c > 2 || mn * 2 != mx) ans = false\n }\n } else {\n if (c == 1) {\n if (2 * mn != mx) ans = false\n } else if (c == 2) {\n if (2 * mn - 1 != mx) ans = false\n } else {\n ans = false\n }\n for (i in mn + 1..mx) {\n if (a.count { it == i } < 2) ans = false\n }\n }\n println(if (ans) \"Possible\" else \"Impossible\")\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nAoki loves numerical sequences and trees.\n\nOne day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree.\n\nAoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1.\n\nDetermine whether such a tree exists.\n\nConstraints\n\n2 ≦ N ≦ 100\n\n1 ≦ a_i ≦ N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf there exists a tree that satisfies the condition, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n5\n3 2 2 3 3\n\nSample Output 1\n\nPossible\n\nThe diagram above shows an example of a tree that satisfies the conditions. The red arrows show paths from each vertex to the farthest vertex from it.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\nPossible\n\nSample Input 4\n\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4\n\nImpossible\n\nSample Input 5\n\n6\n1 1 1 1 1 5\n\nSample Output 5\n\nImpossible\n\nSample Input 6\n\n5\n4 3 2 3 4\n\nSample Output 6\n\nPossible", "sample_input": "5\n3 2 2 3 3\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03988", "source_text": "Score : 700 points\n\nProblem Statement\n\nAoki loves numerical sequences and trees.\n\nOne day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree.\n\nAoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1.\n\nDetermine whether such a tree exists.\n\nConstraints\n\n2 ≦ N ≦ 100\n\n1 ≦ a_i ≦ N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf there exists a tree that satisfies the condition, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n5\n3 2 2 3 3\n\nSample Output 1\n\nPossible\n\nThe diagram above shows an example of a tree that satisfies the conditions. The red arrows show paths from each vertex to the farthest vertex from it.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\nPossible\n\nSample Input 4\n\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4\n\nImpossible\n\nSample Input 5\n\n6\n1 1 1 1 1 5\n\nSample Output 5\n\nImpossible\n\nSample Input 6\n\n5\n4 3 2 3 4\n\nSample Output 6\n\nPossible", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 632, "cpu_time_ms": 236, "memory_kb": 37932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s036637614", "group_id": "codeNet:p03994", "input_text": "fun main(args: Array) {\n val mod = ('z' - 'a').toInt()\n \n val s = readInputLine().toCharArray()\n var K = readInputLine().toInt()\n \n for ((i, c) in s.withIndex()) {\n if (K >= ('z' - c) + 1) {\n s[i] = 'a'\n K -= ('z' - c) + 1\n }\n }\n \n s[s.size - 1] = (((s[s.size - 1] - 'a').toInt() + K) % ('z' - 'a' + 1).toInt() + 'a'.toInt()).toChar()\n\n println(s.joinToString(\"\"))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "language": "Kotlin", "metadata": {"date": 1572671171, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03994.html", "problem_id": "p03994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03994/input.txt", "sample_output_relpath": "derived/input_output/data/p03994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03994/Kotlin/s036637614.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s036637614", "user_id": "u505558493"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "fun main(args: Array) {\n val mod = ('z' - 'a').toInt()\n \n val s = readInputLine().toCharArray()\n var K = readInputLine().toInt()\n \n for ((i, c) in s.withIndex()) {\n if (K >= ('z' - c) + 1) {\n s[i] = 'a'\n K -= ('z' - c) + 1\n }\n }\n \n s[s.size - 1] = (((s[s.size - 1] - 'a').toInt() + K) % ('z' - 'a' + 1).toInt() + 'a'.toInt()).toChar()\n\n println(s.joinToString(\"\"))\n}\n\nfun readInputLine(): String {\n return readLine()!!\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "sample_input": "xyz\n4\n"}, "reference_outputs": ["aya\n"], "source_document_id": "p03994", "source_text": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 498, "cpu_time_ms": 319, "memory_kb": 38644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s696691624", "group_id": "codeNet:p03994", "input_text": "fun main(args: Array) = IO().exec {\n val s = string().toCharArray()\n var k = long()\n for (i in s.indices) {\n if (s[i] != 'a' && 'z' + 1 - s[i] <= k) {\n k -= 'z' + 1 - s[i]\n s[i] = 'a'\n }\n }\n if (k > 0) s[s.size-1] =\n (((s[s.size-1].toLong() + k - 'a'.toLong()) % 26).toInt() + 'a'.toInt()).toChar()\n println(s.joinToString(\"\"))\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}\n// endregion", "language": "Kotlin", "metadata": {"date": 1566874832, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03994.html", "problem_id": "p03994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03994/input.txt", "sample_output_relpath": "derived/input_output/data/p03994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03994/Kotlin/s696691624.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s696691624", "user_id": "u095834727"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "fun main(args: Array) = IO().exec {\n val s = string().toCharArray()\n var k = long()\n for (i in s.indices) {\n if (s[i] != 'a' && 'z' + 1 - s[i] <= k) {\n k -= 'z' + 1 - s[i]\n s[i] = 'a'\n }\n }\n if (k > 0) s[s.size-1] =\n (((s[s.size-1].toLong() + k - 'a'.toLong()) % 26).toInt() + 'a'.toInt()).toChar()\n println(s.joinToString(\"\"))\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}\n// endregion", "problem_context": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "sample_input": "xyz\n4\n"}, "reference_outputs": ["aya\n"], "source_document_id": "p03994", "source_text": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2557, "cpu_time_ms": 276, "memory_kb": 38688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s271839211", "group_id": "codeNet:p03997", "input_text": "fun main(args: Array) {\n val a = readLine()!!.toInt()\n val b = readLine()!!.toInt()\n val h = readLine()!!.toInt()\n\n println((a + b) * h / 2)\n}", "language": "Kotlin", "metadata": {"date": 1593288595, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03997.html", "problem_id": "p03997", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03997/input.txt", "sample_output_relpath": "derived/input_output/data/p03997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03997/Kotlin/s271839211.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271839211", "user_id": "u621958170"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "fun main(args: Array) {\n val a = readLine()!!.toInt()\n val b = readLine()!!.toInt()\n val h = readLine()!!.toInt()\n\n println((a + b) * h / 2)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "sample_input": "3\n4\n2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03997", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 101, "memory_kb": 34404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s538632905", "group_id": "codeNet:p03998", "input_text": "import java.util.*\nimport kotlin.math.acos\nimport kotlin.math.cos\nimport kotlin.math.round\nimport kotlin.math.sin\n\nfun main(args: Array) {\n val a = ArrayDeque()\n val b = ArrayDeque()\n val c = ArrayDeque()\n\n a.addAll(readString().map { it })\n b.addAll(readString().map { it })\n c.addAll(readString().map { it })\n\n var turn = a.first\n while (true) {\n when (turn) {\n 'a' -> {\n if (a.isEmpty()) {\n println(\"A\")\n return\n }\n turn = a.removeFirst()\n }\n 'b' -> {\n if (b.isEmpty()) {\n println(\"B\")\n return\n }\n turn = b.removeFirst()\n }\n 'c' -> {\n if (c.isEmpty()) {\n println(\"C\")\n return\n }\n turn = c.removeFirst()\n }\n }\n }\n}\n\n// read\nfun readString() = readLine()!!", "language": "Kotlin", "metadata": {"date": 1599875159, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p03998.html", "problem_id": "p03998", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03998/input.txt", "sample_output_relpath": "derived/input_output/data/p03998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03998/Kotlin/s538632905.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538632905", "user_id": "u697467902"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.util.*\nimport kotlin.math.acos\nimport kotlin.math.cos\nimport kotlin.math.round\nimport kotlin.math.sin\n\nfun main(args: Array) {\n val a = ArrayDeque()\n val b = ArrayDeque()\n val c = ArrayDeque()\n\n a.addAll(readString().map { it })\n b.addAll(readString().map { it })\n c.addAll(readString().map { it })\n\n var turn = a.first\n while (true) {\n when (turn) {\n 'a' -> {\n if (a.isEmpty()) {\n println(\"A\")\n return\n }\n turn = a.removeFirst()\n }\n 'b' -> {\n if (b.isEmpty()) {\n println(\"B\")\n return\n }\n turn = b.removeFirst()\n }\n 'c' -> {\n if (c.isEmpty()) {\n println(\"C\")\n return\n }\n turn = c.removeFirst()\n }\n }\n }\n}\n\n// read\nfun readString() = readLine()!!", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "sample_input": "aca\naccc\nca\n"}, "reference_outputs": ["A\n"], "source_document_id": "p03998", "source_text": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1039, "cpu_time_ms": 105, "memory_kb": 34844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s717760161", "group_id": "codeNet:p03998", "input_text": "fun main(args: Array){\n var a = readLine()!!.map { it.toString() }.toMutableList()\n var b = readLine()!!.map { it.toString() }.toMutableList()\n var c = readLine()!!.map { it.toString() }.toMutableList()\n\n var str = a.removeAt(0)\n\n while (true){\n if(str == \"a\"){\n if(a.size <= 0){\n println(\"A\")\n break\n }else{\n str = a.removeAt(0)\n }\n }else if(str == \"b\"){\n if(b.size <= 0){\n println(\"B\")\n break\n }else{\n str = b.removeAt(0)\n }\n }else{\n if(c.size <= 0){\n println(\"C\")\n break\n }else{\n str = c.removeAt(0)\n }\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1581731244, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p03998.html", "problem_id": "p03998", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03998/input.txt", "sample_output_relpath": "derived/input_output/data/p03998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03998/Kotlin/s717760161.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s717760161", "user_id": "u035856025"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "fun main(args: Array){\n var a = readLine()!!.map { it.toString() }.toMutableList()\n var b = readLine()!!.map { it.toString() }.toMutableList()\n var c = readLine()!!.map { it.toString() }.toMutableList()\n\n var str = a.removeAt(0)\n\n while (true){\n if(str == \"a\"){\n if(a.size <= 0){\n println(\"A\")\n break\n }else{\n str = a.removeAt(0)\n }\n }else if(str == \"b\"){\n if(b.size <= 0){\n println(\"B\")\n break\n }else{\n str = b.removeAt(0)\n }\n }else{\n if(c.size <= 0){\n println(\"C\")\n break\n }else{\n str = c.removeAt(0)\n }\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "sample_input": "aca\naccc\nca\n"}, "reference_outputs": ["A\n"], "source_document_id": "p03998", "source_text": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 801, "cpu_time_ms": 214, "memory_kb": 33532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s703229867", "group_id": "codeNet:p04000", "input_text": "fun main(arg: Array) {\n val (H, W, N) = listOfInt()\n val M = mutableMapOf, Int>()\n repeat(N) {\n val (a, b) = listOfInt(-1)\n for (h in -1 .. 1) for (w in -1 .. 1) {\n val key = a + h to b + w\n if ((key.first in 1 until H - 1) && (key.second in 1 until W - 1))\n M.set(a + h to b + w, M.getOrElse(a + h to b + w, { 0 }) + 1)\n }\n }\n val ans = LongArray(10)\n M.values.forEach { n -> ans[n] = ans[n] + 1 }\n ans[0] = (1L * (H - 2) * (W - 2)) - ans.sum()\n ans.forEach { println(it) }\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n\n", "language": "Kotlin", "metadata": {"date": 1586402982, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04000.html", "problem_id": "p04000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04000/input.txt", "sample_output_relpath": "derived/input_output/data/p04000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04000/Kotlin/s703229867.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s703229867", "user_id": "u043150661"}, "prompt_components": {"gold_output": "0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n", "input_to_evaluate": "fun main(arg: Array) {\n val (H, W, N) = listOfInt()\n val M = mutableMapOf, Int>()\n repeat(N) {\n val (a, b) = listOfInt(-1)\n for (h in -1 .. 1) for (w in -1 .. 1) {\n val key = a + h to b + w\n if ((key.first in 1 until H - 1) && (key.second in 1 until W - 1))\n M.set(a + h to b + w, M.getOrElse(a + h to b + w, { 0 }) + 1)\n }\n }\n val ans = LongArray(10)\n M.values.forEach { n -> ans[n] = ans[n] + 1 }\n ans[0] = (1L * (H - 2) * (W - 2)) - ans.sum()\n ans.forEach { println(it) }\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "sample_input": "4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n"}, "reference_outputs": ["0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n"], "source_document_id": "p04000", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 972, "cpu_time_ms": 2943, "memory_kb": 202784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s063348113", "group_id": "codeNet:p04000", "input_text": "fun main(arg: Array) {\n val (H, W, N) = listOfInt()\n val M = mutableMapOf, Int>()\n repeat(N) {\n val (a, b) = listOfInt(-1)\n for (h in -1 .. 1) for (w in -1 .. 1) {\n val key = a + h to b + w\n if ((key.first in 1 until H - 1) && (key.second in 1 until W - 1))\n M.set(a + h to b + w, M.getOrElse(a + h to b + w, { 0 }) + 1)\n }\n }\n val ans = LongArray(10)\n M.forEach { m -> ans[m.value] = ans[m.value] + 1 }\n ans[0] = (1L * (H - 2) * (W - 2)) - ans.sum()\n ans.forEach { println(it) }\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n\n", "language": "Kotlin", "metadata": {"date": 1586401877, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04000.html", "problem_id": "p04000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04000/input.txt", "sample_output_relpath": "derived/input_output/data/p04000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04000/Kotlin/s063348113.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s063348113", "user_id": "u043150661"}, "prompt_components": {"gold_output": "0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n", "input_to_evaluate": "fun main(arg: Array) {\n val (H, W, N) = listOfInt()\n val M = mutableMapOf, Int>()\n repeat(N) {\n val (a, b) = listOfInt(-1)\n for (h in -1 .. 1) for (w in -1 .. 1) {\n val key = a + h to b + w\n if ((key.first in 1 until H - 1) && (key.second in 1 until W - 1))\n M.set(a + h to b + w, M.getOrElse(a + h to b + w, { 0 }) + 1)\n }\n }\n val ans = LongArray(10)\n M.forEach { m -> ans[m.value] = ans[m.value] + 1 }\n ans[0] = (1L * (H - 2) * (W - 2)) - ans.sum()\n ans.forEach { println(it) }\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "sample_input": "4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n"}, "reference_outputs": ["0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n"], "source_document_id": "p04000", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 977, "cpu_time_ms": 2819, "memory_kb": 205076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s756670260", "group_id": "codeNet:p04005", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map(String::toLong)\n fun isEven(v: Long): Boolean {\n return v % 2L == 0L\n }\n if (isEven(a) || isEven(b) || isEven(c)) {\n println(0)\n } else {\n val ab = a * b\n println(ab * ((c / 2) + 1) - ab * (c / 2))\n }\n}\n\n\n\n", "language": "Kotlin", "metadata": {"date": 1589901297, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04005.html", "problem_id": "p04005", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04005/input.txt", "sample_output_relpath": "derived/input_output/data/p04005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04005/Kotlin/s756670260.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s756670260", "user_id": "u085288971"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map(String::toLong)\n fun isEven(v: Long): Boolean {\n return v % 2L == 0L\n }\n if (isEven(a) || isEven(b) || isEven(c)) {\n println(0)\n } else {\n val ab = a * b\n println(ab * ((c / 2) + 1) - ab * (c / 2))\n }\n}\n\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "sample_input": "3 3 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p04005", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 329, "cpu_time_ms": 238, "memory_kb": 37780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s115753336", "group_id": "codeNet:p04005", "input_text": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toLong() }\n println(when {\n a % 2 == 0L ||\n b % 2 == 0L ||\n c % 2 == 0L -> 0\n else -> Math.min(b * c, Math.min(a * b, a * c))\n })\n}", "language": "Kotlin", "metadata": {"date": 1584593427, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04005.html", "problem_id": "p04005", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04005/input.txt", "sample_output_relpath": "derived/input_output/data/p04005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04005/Kotlin/s115753336.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115753336", "user_id": "u733811860"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "fun main(args: Array) {\n val (a, b, c) = readLine()!!.split(\" \").map { it.toLong() }\n println(when {\n a % 2 == 0L ||\n b % 2 == 0L ||\n c % 2 == 0L -> 0\n else -> Math.min(b * c, Math.min(a * b, a * c))\n })\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "sample_input": "3 3 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p04005", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 250, "cpu_time_ms": 234, "memory_kb": 35976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s343330308", "group_id": "codeNet:p04011", "input_text": "import java.util.*\n\nfun main(args:Array){\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n val x = readLine()!!.toInt()\n val y = readLine()!!.toInt()\n println(if(n <= k) n * x else k * x + (n - k) * y)\n}\n", "language": "Kotlin", "metadata": {"date": 1580353492, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04011/input.txt", "sample_output_relpath": "derived/input_output/data/p04011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04011/Kotlin/s343330308.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343330308", "user_id": "u480831358"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "import java.util.*\n\nfun main(args:Array){\n val n = readLine()!!.toInt()\n val k = readLine()!!.toInt()\n val x = readLine()!!.toInt()\n val y = readLine()!!.toInt()\n println(if(n <= k) n * x else k * x + (n - k) * y)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "sample_input": "5\n3\n10000\n9000\n"}, "reference_outputs": ["48000\n"], "source_document_id": "p04011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 239, "cpu_time_ms": 201, "memory_kb": 33720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s612956445", "group_id": "codeNet:p04013", "input_text": "fun main(arg: Array) {\n val (N, K) = listOfInt()\n val X = listOfInt()\n val dp = Array(N + 1) { LongArray(N * 50 + 1) }\n dp[0][0] = 1\n for (i in 0 until N) {\n for (j in (0 until N).reversed()) {\n for (k in 0 .. N * 50 - X[i]) {\n dp[j + 1][k + X[i]] += dp[j][k]\n }\n }\n }\n var ans = 0L\n for (j in 1 .. N) ans += dp[j][K * j]\n println(ans)\n\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n\n", "language": "Kotlin", "metadata": {"date": 1586445205, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04013.html", "problem_id": "p04013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04013/input.txt", "sample_output_relpath": "derived/input_output/data/p04013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04013/Kotlin/s612956445.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s612956445", "user_id": "u043150661"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "fun main(arg: Array) {\n val (N, K) = listOfInt()\n val X = listOfInt()\n val dp = Array(N + 1) { LongArray(N * 50 + 1) }\n dp[0][0] = 1\n for (i in 0 until N) {\n for (j in (0 until N).reversed()) {\n for (k in 0 .. N * 50 - X[i]) {\n dp[j + 1][k + X[i]] += dp[j][k]\n }\n }\n }\n var ans = 0L\n for (j in 1 .. N) ans += dp[j][K * j]\n println(ans)\n\n}\n\nfun next() = readLine()!!\nfun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta\nfun nextLong() = next().toLong()\nfun nextDouble() = next().toDouble()\nfun listOfString() = next().split(\" \")\nfun listOfInt() = listOfString().map(String::toInt)\nfun listOfLong() = listOfString().map(String::toLong)\nfun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "sample_input": "4 8\n7 9 8 9\n"}, "reference_outputs": ["5\n"], "source_document_id": "p04013", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 815, "cpu_time_ms": 277, "memory_kb": 42388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s619443273", "group_id": "codeNet:p04019", "input_text": "fun main(args: Array) {\n\n val s = readLine()!!\n\n val se = s.contains('E') && s.contains('W') ||\n (!s.contains('E') && !s.contains('W'))\n val ns = s.contains('S') && s.contains('N') ||\n !s.contains('S') && !s.contains('N')\n\n if(se && ns){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}\n\n", "language": "Kotlin", "metadata": {"date": 1589600451, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04019.html", "problem_id": "p04019", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04019/input.txt", "sample_output_relpath": "derived/input_output/data/p04019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04019/Kotlin/s619443273.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s619443273", "user_id": "u085288971"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "fun main(args: Array) {\n\n val s = readLine()!!\n\n val se = s.contains('E') && s.contains('W') ||\n (!s.contains('E') && !s.contains('W'))\n val ns = s.contains('S') && s.contains('N') ||\n !s.contains('S') && !s.contains('N')\n\n if(se && ns){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "sample_input": "SENW\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04019", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 212, "memory_kb": 33632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s068431163", "group_id": "codeNet:p04020", "input_text": "fun main() {\n val n = readInt()\n var pairs = 0L\n var currSum = 0L\n repeat(n) {\n val a = readInt()\n if (a == 0) {\n pairs += currSum/2\n currSum = 0\n }\n else currSum += a\n }\n pairs += currSum/2\n println(pairs)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()", "language": "Kotlin", "metadata": {"date": 1601107248, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p04020.html", "problem_id": "p04020", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04020/input.txt", "sample_output_relpath": "derived/input_output/data/p04020/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04020/Kotlin/s068431163.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s068431163", "user_id": "u984465701"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "fun main() {\n val n = readInt()\n var pairs = 0L\n var currSum = 0L\n repeat(n) {\n val a = readInt()\n if (a == 0) {\n pairs += currSum/2\n currSum = 0\n }\n else currSum += a\n }\n pairs += currSum/2\n println(pairs)\n}\n\n// Input Reader\nprivate fun readLn() = readLine()!!\n\nprivate fun readInt() = readLn().toInt()", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.\nHe has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum number of pairs that Snuke can create.\n\nSample Input 1\n\n4\n4\n0\n3\n2\n\nSample Output 1\n\n4\n\nFor example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).\n\nSample Input 2\n\n8\n2\n0\n1\n6\n0\n8\n2\n1\n\nSample Output 2\n\n9", "sample_input": "4\n4\n0\n3\n2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p04020", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.\nHe has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum number of pairs that Snuke can create.\n\nSample Input 1\n\n4\n4\n0\n3\n2\n\nSample Output 1\n\n4\n\nFor example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).\n\nSample Input 2\n\n8\n2\n0\n1\n6\n0\n8\n2\n1\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 374, "cpu_time_ms": 312, "memory_kb": 56584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s626328502", "group_id": "codeNet:p04021", "input_text": "fun main(args: Array) = IO().exec {\n val n = int()\n val a = LongArray(n){long()}\n val cnt = mutableMapOf()\n for (i in 0 until n step 2) cnt[a[i]] = 1\n a.sort()\n val cnt2 = mutableMapOf()\n for (i in 0 until n step 2) cnt2[a[i]] = 1\n var ret = 0\n for ((k, v) in cnt) ret += v - (cnt2[k] ?: 0)\n println(ret)\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}\n// endregion", "language": "Kotlin", "metadata": {"date": 1565462469, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04021.html", "problem_id": "p04021", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04021/input.txt", "sample_output_relpath": "derived/input_output/data/p04021/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04021/Kotlin/s626328502.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s626328502", "user_id": "u095834727"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "fun main(args: Array) = IO().exec {\n val n = int()\n val a = LongArray(n){long()}\n val cnt = mutableMapOf()\n for (i in 0 until n step 2) cnt[a[i]] = 1\n a.sort()\n val cnt2 = mutableMapOf()\n for (i in 0 until n step 2) cnt2[a[i]] = 1\n var ret = 0\n for ((k, v) in cnt) ret += v - (cnt2[k] ?: 0)\n println(ret)\n}\n\n// region template\noperator fun Int.iterator() = 0.until(this).iterator()\n\nclass IO {\n val printable = 33..126\n val buffer = ByteArray(1024)\n var ptr = 0\n var buflen = 0\n val out = java.io.PrintWriter(System.out)\n fun hasNextByte(): Boolean = if (ptr < buflen) true else {\n ptr = 0\n buflen = System.`in`.read(buffer)\n buflen > 0\n }\n\n fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1\n fun hasNext(): Boolean {\n while (hasNextByte() && buffer[ptr] !in printable) ptr++\n return hasNextByte()\n }\n\n fun string(): String {\n if (!hasNext()) throw java.util.NoSuchElementException()\n val sb = StringBuilder()\n var b = readByte()\n while (b in printable) {\n sb.appendCodePoint(b.toInt())\n b = readByte()\n }\n return sb.toString()\n }\n\n fun long(): Long {\n if (!hasNext()) throw java.util.NoSuchElementException()\n var n = 0L\n var minus = false\n var b = readByte()\n if (b == '-'.toByte()) {\n minus = true\n b = readByte()\n }\n if (b !in '0'.toByte()..'9'.toByte()) {\n throw NumberFormatException()\n }\n while (true) {\n if (b in '0'.toByte()..'9'.toByte()) {\n n *= 10\n n += b - '0'.toByte()\n } else if (b == (-1).toByte() || b !in printable) {\n return if (minus) -n else n\n } else {\n throw NumberFormatException()\n }\n b = readByte()\n }\n }\n\n fun int(): Int {\n val nl = long()\n if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()\n return nl.toInt()\n }\n\n fun double(): Double = string().toDouble()\n fun print(obj: Any) = out.print(obj)\n fun print(i: Int) = out.print(i)\n fun print(l: Long) = out.print(l)\n fun println(obj: Any) = out.println(obj)\n fun println(i: Int) = out.println(i)\n fun println(l: Long) = out.println(l)\n inline fun exec(block: IO.() -> Unit) {\n block()\n out.flush()\n }\n}\n// endregion", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct.\nHe is sorting this sequence in increasing order.\nWith supernatural power, he can perform the following two operations on the sequence in any order:\n\nOperation 1: choose 2 consecutive elements, then reverse the order of those elements.\n\nOperation 2: choose 3 consecutive elements, then reverse the order of those elements.\n\nSnuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9\n\nIf i ≠ j, then A_i ≠ A_j.\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of times Operation 1 that Snuke has to perform.\n\nSample Input 1\n\n4\n2\n4\n3\n1\n\nSample Output 1\n\n1\n\nThe given sequence can be sorted as follows:\n\nFirst, reverse the order of the last three elements. The sequence is now: 2,1,3,4.\n\nThen, reverse the order of the first two elements. The sequence is now: 1,2,3,4.\n\nIn this sequence of operations, Operation 1 is performed once. It is not possible to sort the sequence with less number of Operation 1, thus the answer is 1.\n\nSample Input 2\n\n5\n10\n8\n5\n3\n2\n\nSample Output 2\n\n0", "sample_input": "4\n2\n4\n3\n1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p04021", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct.\nHe is sorting this sequence in increasing order.\nWith supernatural power, he can perform the following two operations on the sequence in any order:\n\nOperation 1: choose 2 consecutive elements, then reverse the order of those elements.\n\nOperation 2: choose 3 consecutive elements, then reverse the order of those elements.\n\nSnuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9\n\nIf i ≠ j, then A_i ≠ A_j.\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of times Operation 1 that Snuke has to perform.\n\nSample Input 1\n\n4\n2\n4\n3\n1\n\nSample Output 1\n\n1\n\nThe given sequence can be sorted as follows:\n\nFirst, reverse the order of the last three elements. The sequence is now: 2,1,3,4.\n\nThen, reverse the order of the first two elements. The sequence is now: 1,2,3,4.\n\nIn this sequence of operations, Operation 1 is performed once. It is not possible to sort the sequence with less number of Operation 1, thus the answer is 1.\n\nSample Input 2\n\n5\n10\n8\n5\n3\n2\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2521, "cpu_time_ms": 445, "memory_kb": 41844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s327969521", "group_id": "codeNet:p04026", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n for (i in 0..(s.length - 2)) {\n if (s[i] == s[i + 1]) {\n println(\"$i ${i+1}\")\n return\n }\n }\n for (i in 0..(s.length - 3)) {\n if (s[i] == s[i + 2]) {\n println(\"$i ${i+2}\")\n return\n }\n }\n}", "language": "Kotlin", "metadata": {"date": 1575423446, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04026.html", "problem_id": "p04026", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04026/input.txt", "sample_output_relpath": "derived/input_output/data/p04026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04026/Kotlin/s327969521.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s327969521", "user_id": "u099066216"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n for (i in 0..(s.length - 2)) {\n if (s[i] == s[i + 1]) {\n println(\"$i ${i+1}\")\n return\n }\n }\n for (i in 0..(s.length - 3)) {\n if (s[i] == s[i + 2]) {\n println(\"$i ${i+2}\")\n return\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04026", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 328, "cpu_time_ms": 245, "memory_kb": 34212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s109467394", "group_id": "codeNet:p04031", "input_text": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val e = if (a.sum() % n == 0) a.sum() / n else a.sum() / n + 1\n println(a.map { Math.pow(it - e.toDouble(), 2.0) }.sum().toInt())\n}", "language": "Kotlin", "metadata": {"date": 1591334238, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04031.html", "problem_id": "p04031", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04031/input.txt", "sample_output_relpath": "derived/input_output/data/p04031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04031/Kotlin/s109467394.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s109467394", "user_id": "u067986264"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "fun main(args: Array) {\n val n = readLine()!!.toInt()\n val a = readLine()!!.split(\" \").map { it.toInt() }\n val e = if (a.sum() % n == 0) a.sum() / n else a.sum() / n + 1\n println(a.map { Math.pow(it - e.toDouble(), 2.0) }.sum().toInt())\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "sample_input": "2\n4 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p04031", "source_text": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 258, "cpu_time_ms": 232, "memory_kb": 37948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s114884995", "group_id": "codeNet:p04032", "input_text": "fun main(args: Array) {\n val s = readLine()!!\n\n fun containsDup(s: String) : Boolean {\n val map = hashMapOf()\n s.forEach {\n map[it] = map.getOrElse(it, { 0 }) + 1\n if (map[it]!! > s.length / 2) {\n return true\n }\n }\n return false\n }\n\n val size = 2\n for (i in 0 .. s.length - 1) {\n if (containsDup(\n s.substring(i, i + size)\n )) {\n print(i + 1)\n print(' ')\n print(i + size)\n return\n }\n }\n println(\"-1 -1\")\n}", "language": "Kotlin", "metadata": {"date": 1569910360, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04032.html", "problem_id": "p04032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04032/input.txt", "sample_output_relpath": "derived/input_output/data/p04032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04032/Kotlin/s114884995.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s114884995", "user_id": "u861095163"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "fun main(args: Array) {\n val s = readLine()!!\n\n fun containsDup(s: String) : Boolean {\n val map = hashMapOf()\n s.forEach {\n map[it] = map.getOrElse(it, { 0 }) + 1\n if (map[it]!! > s.length / 2) {\n return true\n }\n }\n return false\n }\n\n val size = 2\n for (i in 0 .. s.length - 1) {\n if (containsDup(\n s.substring(i, i + size)\n )) {\n print(i + 1)\n print(' ')\n print(i + size)\n return\n }\n }\n println(\"-1 -1\")\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04032", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 617, "cpu_time_ms": 374, "memory_kb": 40268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s605017056", "group_id": "codeNet:p04033", "input_text": "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 \n if (b >= 0) {\n if (a > 0) {\n println(\"Positive\")\n } else {\n println(\"Zero\")\n }\n return\n }\n \n val diff = Math.abs(b - a)\n if (diff % 2 == 0) {\n println(\"Negative\")\n } else {\n println(\"Positive\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1582845897, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04033.html", "problem_id": "p04033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04033/input.txt", "sample_output_relpath": "derived/input_output/data/p04033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04033/Kotlin/s605017056.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s605017056", "user_id": "u733811860"}, "prompt_components": {"gold_output": "Positive\n", "input_to_evaluate": "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 \n if (b >= 0) {\n if (a > 0) {\n println(\"Positive\")\n } else {\n println(\"Zero\")\n }\n return\n }\n \n val diff = Math.abs(b - a)\n if (diff % 2 == 0) {\n println(\"Negative\")\n } else {\n println(\"Positive\")\n }\n}", "problem_context": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "sample_input": "1 3\n"}, "reference_outputs": ["Positive\n"], "source_document_id": "p04033", "source_text": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 186, "memory_kb": 31400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s767034883", "group_id": "codeNet:p04033", "input_text": "fun main(args : Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (a <= 0 && b >= 0) {\n println(\"Zero\")\n return\n }\n\n if (a > 0) {\n println(\"Positive\")\n return\n }\n\n if (a == b || (b - a + 1) % 2 == 0) {\n println(\"Positive\")\n } else {\n println(\"Negative\")\n }\n}", "language": "Kotlin", "metadata": {"date": 1573641771, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04033.html", "problem_id": "p04033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04033/input.txt", "sample_output_relpath": "derived/input_output/data/p04033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04033/Kotlin/s767034883.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s767034883", "user_id": "u262403099"}, "prompt_components": {"gold_output": "Positive\n", "input_to_evaluate": "fun main(args : Array) {\n val (a, b) = readLine()!!.split(\" \").map { it.toInt() }\n\n if (a <= 0 && b >= 0) {\n println(\"Zero\")\n return\n }\n\n if (a > 0) {\n println(\"Positive\")\n return\n }\n\n if (a == b || (b - a + 1) % 2 == 0) {\n println(\"Positive\")\n } else {\n println(\"Negative\")\n }\n}", "problem_context": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "sample_input": "1 3\n"}, "reference_outputs": ["Positive\n"], "source_document_id": "p04033", "source_text": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 353, "cpu_time_ms": 234, "memory_kb": 38028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s922853046", "group_id": "codeNet:p04043", "input_text": "fun main() {\n val list = readLine()!!.split(\" \").map { it.toInt() }\n var fiveCount = 0\n var sevenCount = 0\n for (i in list) {\n if (i == 5) fiveCount++\n if (i == 7) sevenCount++\n }\n if (fiveCount == 2 && sevenCount == 1) println(\"YES\") else println(\"NO\")\n}", "language": "Kotlin", "metadata": {"date": 1594611136, "filename_ext": "kt", "original_language": "Kotlin (1.3.71)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04043/input.txt", "sample_output_relpath": "derived/input_output/data/p04043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04043/Kotlin/s922853046.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s922853046", "user_id": "u817663013"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "fun main() {\n val list = readLine()!!.split(\" \").map { it.toInt() }\n var fiveCount = 0\n var sevenCount = 0\n for (i in list) {\n if (i == 5) fiveCount++\n if (i == 7) sevenCount++\n }\n if (fiveCount == 2 && sevenCount == 1) println(\"YES\") else println(\"NO\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 112, "memory_kb": 36320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s197066118", "group_id": "codeNet:p04043", "input_text": "\nfun main(args: Array){\n val sentences = getSentences()\n \n val ret = if(sentences[0].length == 5 && sentences[1].length == 7 && sentences[2].length == 5){\n \"YES\"\n }else{\n \"NO\"\n }\n \n println(ret)\n}\n\nfun getSentences(): List{\n return readLine()!!.split(\" \")\n}", "language": "Kotlin", "metadata": {"date": 1588445391, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04043/input.txt", "sample_output_relpath": "derived/input_output/data/p04043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04043/Kotlin/s197066118.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s197066118", "user_id": "u615070501"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "\nfun main(args: Array){\n val sentences = getSentences()\n \n val ret = if(sentences[0].length == 5 && sentences[1].length == 7 && sentences[2].length == 5){\n \"YES\"\n }else{\n \"NO\"\n }\n \n println(ret)\n}\n\nfun getSentences(): List{\n return readLine()!!.split(\" \")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 311, "cpu_time_ms": 242, "memory_kb": 35940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s612459509", "group_id": "codeNet:p04045", "input_text": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map{it.toInt()}\n val d = readLine()!!.split(\" \")\n\n for (i in n..100000) {\n var f = true\n for (x in d) {\n f = f && !(x in i.toString())\n }\n if (f) {\n println(i)\n return\n }\n }\n}\n", "language": "Kotlin", "metadata": {"date": 1552181691, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04045/input.txt", "sample_output_relpath": "derived/input_output/data/p04045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04045/Kotlin/s612459509.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s612459509", "user_id": "u868099754"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "const val MOD: Long = (1e9+7).toLong()\n\nfun main(args: Array) {\n val (n, k) = readLine()!!.split(\" \").map{it.toInt()}\n val d = readLine()!!.split(\" \")\n\n for (i in n..100000) {\n var f = true\n for (x in d) {\n f = f && !(x in i.toString())\n }\n if (f) {\n println(i)\n return\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 324, "memory_kb": 42420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s532481994", "group_id": "codeNet:p04045", "input_text": "/**\n * Created by karayuu on 2018/07/03\n */\nfun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val dislikeNums = readLine()!!.split(\" \")\n var n_s = n.toString().map { it.toString() }\n\n while (!n_s.none { dislikeNums.contains(it) }) {\n n++\n n_s = n.toString().map { it.toString() }\n }\n\n print(n)\n\n}\n", "language": "Kotlin", "metadata": {"date": 1530663840, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04045/input.txt", "sample_output_relpath": "derived/input_output/data/p04045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04045/Kotlin/s532481994.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s532481994", "user_id": "u598902504"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "/**\n * Created by karayuu on 2018/07/03\n */\nfun main(args: Array) {\n var (n, k) = readLine()!!.split(\" \").map { it.toInt() }\n val dislikeNums = readLine()!!.split(\" \")\n var n_s = n.toString().map { it.toString() }\n\n while (!n_s.none { dislikeNums.contains(it) }) {\n n++\n n_s = n.toString().map { it.toString() }\n }\n\n print(n)\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 372, "memory_kb": 47988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Kotlin:s664735330", "group_id": "codeNet:p04046", "input_text": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nclass ModInt(x: Long) {\n\n companion object {\n const val MOD = 1e9.toLong() + 7\n }\n\n val x = (x % MOD + MOD) % MOD\n\n operator fun plus(other: ModInt): ModInt {\n return ModInt(x + other.x)\n }\n\n operator fun minus(other: ModInt): ModInt {\n return ModInt(x - other.x)\n }\n\n operator fun times(other: ModInt): ModInt {\n return ModInt(x * other.x)\n }\n\n operator fun div(other: ModInt): ModInt {\n return this * other.inv()\n }\n\n fun pow(exp: Long): ModInt {\n if (exp == 0L) return ModInt(1L)\n var a = pow(exp shr 1)\n a *= a\n if (exp and 1L == 0L) return a\n return this * a\n }\n\n fun inv(): ModInt {\n return this.pow(MOD - 2)\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n\n other as ModInt\n\n if (x != other.x) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n return x.hashCode()\n }\n\n override fun toString(): String {\n return \"$x\"\n }\n\n}\n\nval fac = mutableListOf()\n\nprivate fun fact(n: Long): ModInt {\n if (fac.count() == 0) fac.add(ModInt(1))\n while (fac.count() <= n) {\n fac.add(fac.last() * ModInt(fac.count().toLong()))\n }\n return fac[n.toInt()]\n}\n\nprivate fun comb(n: Long, k: Long): ModInt {\n return fact(n) / fact(k) / fact(n - k)\n}\n\nprivate fun comb2(n: Long, k: Long): ModInt {\n var ans = ModInt(1)\n for (i in 0 until k) {\n ans = ans * ModInt(n - i) / ModInt(k - i)\n }\n return ans\n}\n\nfun PrintWriter.solve(sc: FastScanner) {\n val h = sc.nextLong()\n val w = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n var ans = ModInt(0L)\n for (i in 1..h - a) {\n if (b == w - 1 && i != h - a) continue\n val c1 = comb(i - 1 + b, b)\n val c2 = comb(h - i + w - b - if (i != h - a) 2 else 1, h - i)\n val c = c1 * c2\n ans += c\n }\n println(ans)\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}", "language": "Kotlin", "metadata": {"date": 1586397003, "filename_ext": "kt", "original_language": "Kotlin (1.0.0)", "problem_description_relpath": "problem_descriptions/p04046.html", "problem_id": "p04046", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04046/input.txt", "sample_output_relpath": "derived/input_output/data/p04046/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04046/Kotlin/s664735330.kt", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s664735330", "user_id": "u190507186"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader\nimport java.io.InputStream\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.lang.StringBuilder\nimport java.util.*\n\nclass ModInt(x: Long) {\n\n companion object {\n const val MOD = 1e9.toLong() + 7\n }\n\n val x = (x % MOD + MOD) % MOD\n\n operator fun plus(other: ModInt): ModInt {\n return ModInt(x + other.x)\n }\n\n operator fun minus(other: ModInt): ModInt {\n return ModInt(x - other.x)\n }\n\n operator fun times(other: ModInt): ModInt {\n return ModInt(x * other.x)\n }\n\n operator fun div(other: ModInt): ModInt {\n return this * other.inv()\n }\n\n fun pow(exp: Long): ModInt {\n if (exp == 0L) return ModInt(1L)\n var a = pow(exp shr 1)\n a *= a\n if (exp and 1L == 0L) return a\n return this * a\n }\n\n fun inv(): ModInt {\n return this.pow(MOD - 2)\n }\n\n override fun equals(other: Any?): Boolean {\n if (this === other) return true\n if (javaClass != other?.javaClass) return false\n\n other as ModInt\n\n if (x != other.x) return false\n\n return true\n }\n\n override fun hashCode(): Int {\n return x.hashCode()\n }\n\n override fun toString(): String {\n return \"$x\"\n }\n\n}\n\nval fac = mutableListOf()\n\nprivate fun fact(n: Long): ModInt {\n if (fac.count() == 0) fac.add(ModInt(1))\n while (fac.count() <= n) {\n fac.add(fac.last() * ModInt(fac.count().toLong()))\n }\n return fac[n.toInt()]\n}\n\nprivate fun comb(n: Long, k: Long): ModInt {\n return fact(n) / fact(k) / fact(n - k)\n}\n\nprivate fun comb2(n: Long, k: Long): ModInt {\n var ans = ModInt(1)\n for (i in 0 until k) {\n ans = ans * ModInt(n - i) / ModInt(k - i)\n }\n return ans\n}\n\nfun PrintWriter.solve(sc: FastScanner) {\n val h = sc.nextLong()\n val w = sc.nextLong()\n val a = sc.nextLong()\n val b = sc.nextLong()\n var ans = ModInt(0L)\n for (i in 1..h - a) {\n if (b == w - 1 && i != h - a) continue\n val c1 = comb(i - 1 + b, b)\n val c2 = comb(h - i + w - b - if (i != h - a) 2 else 1, h - i)\n val c = c1 * c2\n ans += c\n }\n println(ans)\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}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a large square grid with H rows and W columns.\nIroha is now standing in the top-left cell.\nShe will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.\n\nHowever, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells.\n\nFind the number of ways she can travel to the bottom-right cell.\n\nSince this number can be extremely large, print the number modulo 10^9+7.\n\nConstraints\n\n1 ≦ H, W ≦ 100,000\n\n1 ≦ A < H\n\n1 ≦ B < W\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nPrint the number of ways she can travel to the bottom-right cell, modulo 10^9+7.\n\nSample Input 1\n\n2 3 1 1\n\nSample Output 1\n\n2\n\nWe have a 2×3 grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: \"Right, Right, Down\" and \"Right, Down, Right\".\n\nSample Input 2\n\n10 7 3 4\n\nSample Output 2\n\n3570\n\nThere are 12 forbidden cells.\n\nSample Input 3\n\n100000 100000 99999 99999\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100000 100000 44444 55555\n\nSample Output 4\n\n738162020", "sample_input": "2 3 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04046", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a large square grid with H rows and W columns.\nIroha is now standing in the top-left cell.\nShe will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.\n\nHowever, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells.\n\nFind the number of ways she can travel to the bottom-right cell.\n\nSince this number can be extremely large, print the number modulo 10^9+7.\n\nConstraints\n\n1 ≦ H, W ≦ 100,000\n\n1 ≦ A < H\n\n1 ≦ B < W\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nPrint the number of ways she can travel to the bottom-right cell, modulo 10^9+7.\n\nSample Input 1\n\n2 3 1 1\n\nSample Output 1\n\n2\n\nWe have a 2×3 grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: \"Right, Right, Down\" and \"Right, Down, Right\".\n\nSample Input 2\n\n10 7 3 4\n\nSample Output 2\n\n3570\n\nThere are 12 forbidden cells.\n\nSample Input 3\n\n100000 100000 99999 99999\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100000 100000 44444 55555\n\nSample Output 4\n\n738162020", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2798, "cpu_time_ms": 469, "memory_kb": 116520}, "variant": "medium_resource"}